[QGIS-Developer] qgis plugin crashes on Windows with access violation

Martin Landa landa.martin at gmail.com
Wed Jan 15 08:46:46 PST 2025


Hi all,

One of the qgis plugins I contribute to has a serious problem under
Windows. It crashes with

"""
Python Stack Trace

Windows fatal exception: access violation


Current thread 0x00000168 (most recent call first):

  Thread 0x0000268c (most recent call first):


Stack Trace


RtlpWaitOnCriticalSection :
RtlpEnterCriticalSectionContended :
RtlEnterCriticalSection :
xmlDictFree :
PyGen_Finalize :
PyThreadState_Clear :
PyGILState_Release :
PyInit_sip :
pdal::StreamPointTable::reset :
QgsPresetSchemeColorRamp::clone :
QgsTask::start :
QThreadPoolPrivate::reset :
QThread::start :
BaseThreadInitThunk :
RtlUserThreadStart :

QGIS Info
QGIS Version: 3.34.14-Prizren
QGIS code revision: 0cdaf6d9
Compiled against Qt: 5.15.13
Running against Qt: 5.15.13
Compiled against GDAL: 3.9.3
Running against GDAL: 3.9.3

System Info
CPU Type: x86_64
Kernel Type: winnt
Kernel Version: 10.0.22631

"""

Which means that the whole QGIS ends unexpectedly. The plugin has this
issue only on Windows. On Linux it runs successfully. When trying to
discover what is the source of this crash I created a sample minimalistic
plugin which is reproducible [1]. Install this plugin from zip and push the
"Run". After a few seconds the plugin crashes and QGIS ends on Windows.

The plugin uses QgsTask-based class which performs two operations on
background:

"""
class crashTask(QgsTask):
    def run(self):
        wfs = WebFeatureService(url="
https://geoforall.fsv.cvut.cz/st_lucas/geoserver/wfs", version='1.1.0')

        ds = ogr.Open(Path(__file__).parent / "lucas_test.gpkg")
        return True
"""

When I comment out one of the lines ("wfs = ..." or "ds = ..."), the plugin
doesn't crash. Only both statements performed together cause a crash.

In the case that these two statements are performed outside of the
crashTask instance, eg.

"""
class CrashPlugin:
   ...
    def onRun(self):
        wfs = WebFeatureService(url="
https://geoforall.fsv.cvut.cz/st_lucas/geoserver/wfs", version='1.1.0')

        ds = ogr.Open(Path(__file__).parent / "lucas_test.gpkg")
"""

The plugin also doesn't crash. The plugin only crashes when these two lines
are located in the crashTask.run method.

Do you have any idea what is wrong or how to find out what can cause such a
crash?

Thanks in advance for any feedback! Martin

[1] https://geo.fsv.cvut.cz/data/landa/crash_plugin.zip

-- 
Martin Landa
https://geomatics.fsv.cvut.cz/en/employees/martin-landa/
https://gismentors.cz/mentors/landa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20250115/5c4e6ac4/attachment.htm>


More information about the QGIS-Developer mailing list