Bug report #17920
It is possible to use the raster calculator to crash QGIS
|Affected QGIS version:||master||Regression?:||No|
|Operating System:||Windows?||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||fixed/implemented|
|Crashes QGIS or corrupts data:||Yes||Copied to github as #:||25816|
- enter a cell size and extents (if you don't there is no crash)
- enter a number as the expression
- run it and it will crash
I presume a number is an invalid expression, although I don't see why it couldn't be valid i.e. so you could use the raster calculator to create a raster filled with a single value.
But in any cash a crash should be avoided.
#2 Updated by Alister Hood about 5 years ago
Sorry, I didn't realise, but master still includes the old raster calculator (accessible from the main menu). With that it is a valid expression, producing the output you would expect. Even something like "jkl" (with the quotes) or "" is a valid expression (producing a raster filled with nan). That calculator also validates the expression and won't let you run it with an invalid expression.
To be clear, this bug is about the new processing raster calculator. This doesn't validate the expression as it is entered, so it is possible to run it with an invalid expression. It seems that it crashes QGIS with any expression that doesn't use an existing raster. If the expression uses an existing raster then it doesn't crash, even if the existing raster is not in the specified extent.
FWIW I am using 64bit master from OSGeo4W
Still reproducible on fcbf4cb1f1, but I was on an earlier build when I reported it.
#3 Updated by Alister Hood about 5 years ago
As I mentioned, if you don't fill in the cell size and extents and you try to run it with an invalid expression then instead of crashing it produces an error message:
Traceback (most recent call last): File "C:/OSGEO4~1/apps/qgis-dev/./python/plugins\processing\algs\qgis\RasterCalculator.py", line 150, in processAlgorithm raise QgsProcessingException(self.tr("No layers selected")) _core.QgsProcessingException: No layers selected Execution failed after 0.03 seconds Loading resulting layers The following layers were not correctly generated. C:/Users/alistair/AppData/Local/Temp/processing_cca6cb7ace2a453aaaa4a4de25d0422c/f788bbd00a2d4b5f8bb5e7287c67c26e/OUTPUT.tif You can check the 'Log Messages Panel' in QGIS main window to find more information about the execution of the algorithm.
#5 Updated by Alister Hood about 5 years ago
Alexander Bruy wrote:
This is not a Processing issue.
I can't comment on that, other than that it is an issue that only occurs when using the raster calculator via Processing rather than via the main menu (Raster>Raster Calculator)
Raster calculator can not be used without input layers. You can easily check this by running native raster calculator using "correct" expression but without loaded layers.
The Raster calculator in the main menu certainly can. I just tested it again to double-check. See the screenshots.
#7 Updated by Alister Hood almost 5 years ago
- Status changed from Closed to Reopened
- Operating System set to Windows?
Still crashes here on Windows 10 (64bit osgeo4w fcb50a6857). I turned off all plugins other than processing, in case they were an issue, and tried deleting the QGIS folder under AppData\Local (although it seems there must still be settings in the registry or somewhere, because it still remembered my recently used algorithms).
But it did work when I tested on a different Windows 10 machine a week ago, and also on Ubuntu...
#9 Updated by Alister Hood almost 5 years ago
- Resolution set to fixed/implemented
- Status changed from Reopened to Closed
Looks good... I wasn't able to test Windows build 2.99.0-292 on the original machine at work (Trend Micro thinks it is a virus).
But it works on the second test machine, and downgrading to 2.99.0-291 crashes there too.