<div dir="ltr"><div dir="ltr"><div>Hi all,</div><div><br></div><div>One of the qgis plugins I contribute to has a serious problem under Windows. It crashes with</div><div><br></div><div>"""</div><div><span style="font-weight:600">Python Stack Trace</span><p></p>
<pre style="margin-top:12px;margin-bottom:0px"><span style="font-family:"Courier New"">Windows fatal exception: access violation</span></pre>
<pre style="margin-top:0px;margin-bottom:0px;font-family:"Courier New""><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New"">Current thread 0x00000168 (most recent call first):</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New""> </span></pre>
<pre style="margin-top:0px;margin-bottom:0px;font-family:"Courier New"">Thread 0x0000268c (most recent call first):</pre>
<pre style="margin-top:0px;margin-bottom:12px"><span style="font-weight:600;font-family:Arial,Helvetica,sans-serif"><br></span></pre><pre style="margin-top:0px;margin-bottom:12px"><span style="font-weight:600;font-family:Arial,Helvetica,sans-serif">Stack Trace</span></pre>
<pre style="margin-top:12px;margin-bottom:12px"><span style="font-family:"Courier New""><br>RtlpWaitOnCriticalSection :<br>RtlpEnterCriticalSectionContended :<br>RtlEnterCriticalSection :<br>xmlDictFree :<br>PyGen_Finalize :<br>PyThreadState_Clear :<br>PyGILState_Release :<br>PyInit_sip :<br>pdal::StreamPointTable::reset :<br>QgsPresetSchemeColorRamp::clone :<br>QgsTask::start :<br>QThreadPoolPrivate::reset :<br>QThread::start :<br>BaseThreadInitThunk :<br>RtlUserThreadStart :<br></span></pre>
<p style="margin:0px"><span style="font-weight:600">QGIS Info</span><br>QGIS Version: 3.34.14-Prizren<br>QGIS code revision: 0cdaf6d9<br>Compiled against Qt: 5.15.13<br>Running against Qt: 5.15.13<br>Compiled against GDAL: 3.9.3<br>Running against GDAL: 3.9.3<br><br><span style="font-weight:600">System Info</span><br>CPU Type: x86_64<br>Kernel Type: winnt<br>Kernel Version: 10.0.22631<br></p><p style="margin:0px">"""</p></div><div><br></div><div>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.</div><div><br></div><div>The plugin uses QgsTask-based class which performs two operations on background:</div><div><br></div><div>"""</div><div>class crashTask(QgsTask):<br> def run(self):<br> wfs = WebFeatureService(url="<a href="https://geoforall.fsv.cvut.cz/st_lucas/geoserver/wfs" target="_blank">https://geoforall.fsv.cvut.cz/st_lucas/geoserver/wfs</a>", version='1.1.0') <br> ds = ogr.Open(Path(__file__).parent / "lucas_test.gpkg")<br> return True</div><div>"""</div><div><br></div><div>When I comment out one of the lines ("wfs = ..." or "ds = ..."), the plugin doesn't crash. Only both statements performed together cause a crash. </div><div><br></div><div>In the case that these two statements are performed outside of the crashTask instance, eg.</div><div><br></div><div>"""</div><div>class CrashPlugin:</div><div> ...</div><div> def onRun(self):</div><div> wfs = WebFeatureService(url="<a href="https://geoforall.fsv.cvut.cz/st_lucas/geoserver/wfs" target="_blank">https://geoforall.fsv.cvut.cz/st_lucas/geoserver/wfs</a>", version='1.1.0') <br></div><div> ds = ogr.Open(Path(__file__).parent / "lucas_test.gpkg")</div><div>"""</div><div><br></div><div>The plugin also doesn't crash. The plugin only crashes when these two lines are located in the crashTask.run method.</div><div><br></div><div>Do you have any idea what is wrong or how to find out what can cause such a crash?</div><div><br></div><div>Thanks in advance for any feedback! Martin</div><div><br></div><div>[1] <a href="https://geo.fsv.cvut.cz/data/landa/crash_plugin.zip">https://geo.fsv.cvut.cz/data/landa/crash_plugin.zip</a></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Martin Landa<div><a href="https://geomatics.fsv.cvut.cz/en/employees/martin-landa/" target="_blank">https://geomatics.fsv.cvut.cz/en/employees/martin-landa/</a><br><a href="https://gismentors.cz/mentors/landa" target="_blank">https://gismentors.cz/mentors/landa</a></div></div></div></div>
</div>