Skip to content

Qgis-server QgsVectorLayerExporter python segmentation fault #121

@Cir02

Description

@Cir02

Hello there,

triying to export some map layers from a .gdb file to Postgis using qgis-server docker image (3.40 and 3.42 have same result) using the pyqgis api, the method QgsVectorLayerExporter produce a python segmentation fault inside the contianer. using faulthandler i was able to catch this error:

Fatal Python error: Segmentation fault

Current thread 0x00007fc68a448140 (most recent call first):
  File "/qgis_data/./code/layers_gdb_shp.py", line 90 in export_tables_psql **(line where method QgsVectorLayerExporter is use)**
  File "/qgis_data/./code/layers_gdb_shp.py", line 112 in <module>

Extension modules: PyQt5.QtCore, PyQt5.QtXml, PyQt5.QtNetwork, PyQt5.QtGui, PyQt5.QtWidgets, PyQt5.QtSql, PyQt5.QtPrintSupport, PyQt5.QtPositioning, PyQt5.QtSerialPort, qgis._core, PyQt5.QtMultimedia, PyQt5.Qsci, qgis._gui, numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, yaml._yaml (total: 27)
Segmentation fault

this is the method call:

def export_tables_psql(ipath,layers, db_user, db_pass):
 
    db_host = "xxx"
    db_port = 5432
    db_database = "xxx"

    project = QgsProject.instance()

    for i in layers:
        layer = QgsVectorLayer(f"{ipath}|layername={i}", f"{i}", "ogr")
        #add layer to project
        QgsProject.instance().addMapLayer(layer)
        lyr = project.mapLayersByName(f'{i}')[0]
        uri = f'dbname=\'{db_database}\' host={db_host} port={db_port} user=\'{db_user}\' password=\'{db_pass}\' sslmode=disable table="qgis_test"."{i}_docker" (geom) key=\'id\' '

        try:
            # uri =  f"dbname='{db_database}' host={db_host} port={db_port} user='{db_user}' password='{db_pass}' sslmode=disable table='qgis_test.{i}_docker' key='id'"
            err = QgsVectorLayerExporter.exportLayer(lyr, uri, "postgres", lyr.crs() )

            if err[0] != QgsVectorLayerExporter.NoError:
                print('Import layer {} failed with error {}'.format( lyr.name(), err) )
            else:
                print('Layer {} import ok'.format( lyr.name() ) )

        except Exception as e:
            print(f"ERROR: {e}")
    
    return

also debugging with gdb i have this output:

  • gdb run
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/x86_64-linux-gnu/libthread_db.so.1".
warning: could not find '.gnu_debugaltlink' file for /usr/lib/python3/dist-packages/PyQt5/QtCore.abi3.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libQt5Network.so.5
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libQt5Svg.so.5
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libQt5WebKitWidgets.so.5
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libQt5PrintSupport.so.5
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libpulse.so.0
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libQt5Sensors.so.5
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libwoff2dec.so.1.0.2
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libxslt.so.1
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libgstapp-1.0.so.0
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libgstbase-1.0.so.0
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libgstpbutils-1.0.so.0
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libgstaudio-1.0.so.0
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libgsttag-1.0.so.0
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libgstvideo-1.0.so.0
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libgstfft-1.0.so.0
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libfyba.so.0
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libogdi.so.4.1
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libmfhdfalt.so.0
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-16.1.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libwoff2common.so.1.0.2
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libbrotlidec.so.1
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/liborc-0.4.so.0
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/liblber.so.2
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libnss3.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libsmime3.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libplc4.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libfyut.so.0
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libfygm.so.0
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libcap.so.2
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libbrotlicommon.so.1
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libnssutil3.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libplds4.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/python3/dist-packages/PyQt5/QtXml.abi3.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/python3/dist-packages/PyQt5/QtNetwork.abi3.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/python3/dist-packages/PyQt5/QtGui.abi3.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/python3/dist-packages/PyQt5/QtWidgets.abi3.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/python3/dist-packages/PyQt5/QtPrintSupport.abi3.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/python3/dist-packages/PyQt5/QtPositioning.abi3.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/python3/dist-packages/PyQt5/QtMultimedia.abi3.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/python3/dist-packages/numpy/core/_multiarray_umath.cpython-312-x86_64-linux-gnu.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/python3/dist-packages/numpy/core/_multiarray_tests.cpython-312-x86_64-linux-gnu.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/python3/dist-packages/numpy/linalg/_umath_linalg.cpython-312-x86_64-linux-gnu.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/python3/dist-packages/numpy/fft/_pocketfft_internal.cpython-312-x86_64-linux-gnu.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/python3/dist-packages/numpy/random/mtrand.cpython-312-x86_64-linux-gnu.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/python3/dist-packages/numpy/random/bit_generator.cpython-312-x86_64-linux-gnu.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/python3/dist-packages/numpy/random/_common.cpython-312-x86_64-linux-gnu.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/python3/dist-packages/numpy/random/_bounded_integers.cpython-312-x86_64-linux-gnu.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/python3/dist-packages/numpy/random/_mt19937.cpython-312-x86_64-linux-gnu.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/python3/dist-packages/numpy/random/_philox.cpython-312-x86_64-linux-gnu.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/python3/dist-packages/numpy/random/_pcg64.cpython-312-x86_64-linux-gnu.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/python3/dist-packages/numpy/random/_sfc64.cpython-312-x86_64-linux-gnu.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/python3/dist-packages/numpy/random/_generator.cpython-312-x86_64-linux-gnu.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqoffscreen.so
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/qt5/plugins/iconengines/libqsvgicon.so
[New Thread 0x7fffd91dd6c0 (LWP 34439)]
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/qt5/plugins/bearer/libqconnmanbearer.so
[New Thread 0x7fffd89a46c0 (LWP 34443)]
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/qt5/plugins/bearer/libqgenericbearer.so
warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/qt5/plugins/bearer/libqnmbearer.so
[Thread 0x7fffd91dd6c0 (LWP 34439) exited]

Thread 1 "python3" received signal SIGSEGV, Segmentation fault.
0x00007ffff7318b24 in QObject::thread() const () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
  • gdb backtrace
#0  0x00007ffff7318b24 in QObject::thread() const () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#1  0x00007fffd976ed4d in ?? () from /usr/lib/qgis/plugins/libprovider_postgres.so
#2  0x00007fffd976f1cc in ?? () from /usr/lib/qgis/plugins/libprovider_postgres.so
#3  0x00007fffd97304f4 in ?? () from /usr/lib/qgis/plugins/libprovider_postgres.so
#4  0x00007fffee83861c in QgsVectorLayerExporter::QgsVectorLayerExporter(QString const&, QString const&, QgsFields const&, Qgis::WkbType, QgsCoordinateReferenceSystem const&, bool, QMap<QString, QVariant> const&, QFlags<QgsFeatureSink::SinkFlag>) () from /lib/libqgis_core.so.3.42.0
#5  0x00007fffee83acb3 in QgsVectorLayerExporter::exportLayer(QgsVectorLayer*, QString const&, QString const&, QgsCoordinateReferenceSystem const&, bool, QString*, QMap<QString, QVariant> const&, QgsFeedback*) () from /lib/libqgis_core.so.3.42.0
#6  0x00007fffdd5bb97f in ?? () from /usr/lib/python3/dist-packages/qgis/_core.cpython-312-x86_64-linux-gnu.so
#7  0x000000000058208f in ?? ()
#8  0x0000000000549185 in _PyObject_MakeTpCall ()
#9  0x00000000005d73c9 in _PyEval_EvalFrameDefault ()
#10 0x00000000005d58eb in PyEval_EvalCode ()
#11 0x0000000000608b42 in ?? ()
#12 0x00000000006b4e93 in ?? ()
#13 0x00000000006b4bfa in _PyRun_SimpleFileObject ()
#14 0x00000000006b4a2f in _PyRun_AnyFileObject ()
#15 0x00000000006bca95 in Py_RunMain ()
#16 0x00000000006bc57d in Py_BytesMain ()
#17 0x00007ffff7ca51ca in __libc_start_call_main (main=main@entry=0x5189b0, argc=argc@entry=12, argv=argv@entry=0x7fffffffe168) at ../sysdeps/nptl/libc_start_call_main.h:58
#18 0x00007ffff7ca528b in __libc_start_main_impl (main=0x5189b0, argc=12, argv=0x7fffffffe168, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe158)
    at ../csu/libc-start.c:360
--Type <RET> for more, q to quit, c to continue without paging--c
#19 0x0000000000657ce5 in _start ()

env var QT_QPA_PLATFORM i set to offscreen

i have try to connect to database via psql with same creds inside container (no problem) and to connect and export via QGIS desktop in windows 11 (also no probelm)

Any ideas what is happening? in January with qgis-server:3.40 image was working fine.

Thanks!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions