REDcatch / Volume_calculation_for_QGIS3

GNU General Public License v3.0
8 stars 7 forks source link

crashes QGIS when I try to run #6

Open AlisterH opened 1 year ago

AlisterH commented 1 year ago

I'm getting a crash. I don't have a stack trace at this stage (am on Windows and only allowed to use the standalone QGIS installer), but I'll post this now in case I can't get it again (previously the crash handler didn't even come up).

Python Stack Trace
Windows fatal exception: access violation

Current thread 0x00005af8 (most recent call first):
  File "C:\PROGRA~1/QGIS32~1.0/apps/qgis/./python/plugins\processing\gui\AlgorithmExecutor.py", line 72 in execute
    results, ok = alg.run(parameters, context, feedback, {}, False)
  File "C:\PROGRA~1/QGIS32~1.0/apps/qgis/./python/plugins\processing\core\Processing.py", line 187 in runAlgorithm
    ret, results = execute(alg, parameters, context, feedback, catch_exceptions=False)
  File "C:\PROGRA~1/QGIS32~1.0/apps/qgis/./python/plugins\processing\tools\general.py", line 108 in run
    return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
  File "C:\Users/alistair/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\volume_calculation_tool\volume_calculation_tool.py", line 619 in getVolumeSimple
    result = processing.run("qgis:zonalstatistics", { 'COLUMN_PREFIX' : SIMPLE_WORKFLOW_HEIGHT_PREFIX, 'INPUT_RASTER' : self.current_task_options.height_layer, 'INPUT_VECTOR': self.current_task_options.vector_layer, 'RASTER_BAND' : self.current_task_options.height_dem_band, 'STATS' : [2] })
  File "C:\Users/alistair/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\volume_calculation_tool\volume_calculation_tool.py", line 477 in doSimpleWorkflow
    self.getVolumeSimple()
  File "C:\Users/alistair/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\volume_calculation_tool\volume_calculation_tool.py", line 474 in workflow
    self.doSimpleWorkflow()
  File "C:\Users/alistair/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\volume_calculation_tool\volume_calculation_tool.py", line 429 in run
    result = self.dlg.exec_()

Stack Trace
No stack trace is available.

QGIS Info
QGIS Version: 3.26.0-Buenos Aires
QGIS code revision: 0aece2818e
Compiled against Qt: 5.15.3
Running against Qt: 5.15.3
Compiled against GDAL: 3.5.0
Running against GDAL: 3.5.0

System Info
CPU Type: x86_64
Kernel Type: winnt
Kernel Version: 10.0.19042
AlisterH commented 1 year ago

I'm not sure, but the crashes may only occur when using "simple mean value" calculation. But they don't occur every time I use it.

distbug commented 1 year ago

From the stack trace it seems that there is an issue with running the "qgis:zonalstatistics" tool. We could not immediately reproduce the error so we'd ask for you to provide us with the dataset and exact settings/inputs you are using.

AlisterH commented 1 year ago

OK, I think that particular crash only occurs when I run a simple mean value calculation and then run it again (without closing the plugin). A user is most likely to do that if they wanted to run the calculation twice with different base heights.
Sometimes the QGIS crash handler appears and other times it doesn't.

distbug commented 1 year ago

The main issue seems to be the call to the qgis:zonalstatistics program used for this calculation, as shown in your stacktrace.

    results, ok = alg.run(parameters, context, feedback, {}, False)
  File "C:\PROGRA~1/QGIS32~1.0/apps/qgis/./python/plugins\processing\core\Processing.py", line 187 in runAlgorithm
    ret, results = execute(alg, parameters, context, feedback, catch_exceptions=False)
  File "C:\PROGRA~1/QGIS32~1.0/apps/qgis/./python/plugins\processing\tools\general.py", line 108 in run
    return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
  File "C:\Users/alistair/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\volume_calculation_tool\volume_calculation_tool.py", line 619 in getVolumeSimple
    result = processing.run("qgis:zonalstatistics", { 'COLUMN_PREFIX' : SIMPLE_WORKFLOW_HEIGHT_PREFIX, 'INPUT_RASTER' : self.current_task_options.height_layer, 'INPUT_VECTOR': self.current_task_options.vector_layer, 'RASTER_BAND' : self.current_task_options.height_dem_band, 'STATS' : [2] })

However since we cannot reproduce that behavior it is difficult for us to estimate where the issue exactly comes from. It may have something to do with the layers we are passing in. Are you using the example dataset we provide, or any other if so what layers are you using ?

AlisterH commented 1 year ago

Further testing seems to show it only occurs when the vector layer is a memory layer. At least, it doesn't occur if it is a shapefile. And I see that it crashes the second time I click "run" with "simple mean value" selected, even if I ran it with "accurate approximation" after running it the first time with "simple mean value".

Also note that there is another bug when using "simple mean value" - it always adds the output fields, even when "Add/Update Volume As Field" is unchecked.