qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.52k stars 2.99k forks source link

Using some functions in raster calulator crashes QGIS 3.10/3.12. #35583

Closed janchytry closed 4 years ago

janchytry commented 4 years ago

Hey, I am on Linux Mint 19.2 Cinnamon using QGIS 3.10 LTR apt package. Every time I use the native raster calculator with an expression, such as the following: ("slope@1" > (6.94*0.85+((max("slope@1")-min("slope@1")))/4))*1 it crashes the whole QGIS without any message.

The expression is valid as well as the raster layer I'm using. I suspect there is a problem with min/max functions, however, not sure about it, and not sure which other functions might be involved.

The expression: ("slope@1" > (6.94*0.85))*1 returned a valid result.

I reproduced the same issue on the 3.12 version.

I launched QGIS 3.12 through the console and captured this log on the crash:

Warning: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QGIS died on signal 11[New LWP 5663]
[New LWP 5664]
[New LWP 5665]
[New LWP 5666]
[New LWP 5673]
[New LWP 5674]
[New LWP 5675]
[New LWP 5676]
[New LWP 5679]
[New LWP 5690]
[New LWP 5691]
[New LWP 5692]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007fda6e2036c2 in __GI___waitpid (pid=5695, stat_loc=0x7ffeb33be6ec, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:30
30  ../sysdeps/unix/sysv/linux/waitpid.c: No such file or directory.
[Current thread is 1 (Thread 0x7fda732fe3c0 (LWP 5660))]
#0  0x00007fda6e2036c2 in __GI___waitpid (pid=5695, stat_loc=0x7ffeb33be6ec, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:30
        resultvar = 18446744073709551104
        sc_cancel_oldtype = 0
#1  0x000055ec465132be in  ()
#2  0x00007fda6e15df20 in <signal handler called> () at /lib/x86_64-linux-gnu/libc.so.6
#3  0x00007fda6c855981 in QgsRasterMatrix::twoArgumentOperation(QgsRasterMatrix::TwoArgOperator, QgsRasterMatrix const&) () at /usr/lib/libqgis_analysis.so.3.12.1
#4  0x00007fda6c846aff in QgsRasterCalcNode::calculate(QMap<QString, QgsRasterBlock*>&, QgsRasterMatrix&, int) const () at /usr/lib/libqgis_analysis.so.3.12.1
#5  0x00007fda6c846a7a in QgsRasterCalcNode::calculate(QMap<QString, QgsRasterBlock*>&, QgsRasterMatrix&, int) const () at /usr/lib/libqgis_analysis.so.3.12.1
#6  0x00007fda6c846a7a in QgsRasterCalcNode::calculate(QMap<QString, QgsRasterBlock*>&, QgsRasterMatrix&, int) const () at /usr/lib/libqgis_analysis.so.3.12.1
#7  0x00007fda6c846ab1 in QgsRasterCalcNode::calculate(QMap<QString, QgsRasterBlock*>&, QgsRasterMatrix&, int) const () at /usr/lib/libqgis_analysis.so.3.12.1
#8  0x00007fda6c846ab1 in QgsRasterCalcNode::calculate(QMap<QString, QgsRasterBlock*>&, QgsRasterMatrix&, int) const () at /usr/lib/libqgis_analysis.so.3.12.1
#9  0x00007fda6c846a7a in QgsRasterCalcNode::calculate(QMap<QString, QgsRasterBlock*>&, QgsRasterMatrix&, int) const () at /usr/lib/libqgis_analysis.so.3.12.1
#10 0x00007fda6c850980 in QgsRasterCalculator::processCalculation(QgsFeedback*) () at /usr/lib/libqgis_analysis.so.3.12.1
#11 0x00007fda72773b4c in QgisApp::showRasterCalculator() () at /usr/lib/libqgis_app.so.3.12.1
#12 0x00007fda6ed6a66f in QMetaObject::activate(QObject*, int, int, void**) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#13 0x00007fda6fab3122 in QAction::triggered(bool) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#14 0x00007fda6fab580c in QAction::activate(QAction::ActionEvent) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#15 0x00007fda6fc320fc in  () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#16 0x00007fda6fc395ab in  () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#17 0x00007fda6fc3a3d3 in QMenu::mouseReleaseEvent(QMouseEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#18 0x00007fda6faf8048 in QWidget::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#19 0x00007fda6fc3c6fb in QMenu::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#20 0x00007fda6fab983c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#21 0x00007fda6fac165f in QApplication::notify(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#22 0x00007fda709b434b in QgsApplication::notify(QObject*, QEvent*) () at /usr/lib/libqgis_core.so.3.12.1
#23 0x00007fda6ed3b8d8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#24 0x00007fda6fac0632 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#25 0x00007fda6fb12ea5 in  () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#26 0x00007fda6fb157da in  () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#27 0x00007fda6fab983c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#28 0x00007fda6fac1104 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#29 0x00007fda709b434b in QgsApplication::notify(QObject*, QEvent*) () at /usr/lib/libqgis_core.so.3.12.1
#30 0x00007fda6ed3b8d8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#31 0x00007fda6f2fd583 in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#32 0x00007fda6f2ff055 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#33 0x00007fda6f2d62eb in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#34 0x00007fda4a187260 in  () at /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#35 0x00007fda62d00417 in g_main_context_dispatch () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#36 0x00007fda62d00650 in  () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#37 0x00007fda62d006dc in g_main_context_iteration () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#38 0x00007fda6ed9488f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#39 0x00007fda6ed3990a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#40 0x00007fda6ed429b4 in QCoreApplication::exec() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#41 0x000055ec4650f56e in  ()
#42 0x00007fda6e140b97 in __libc_start_main (main=0x55ec4650cd10, argc=1, argv=0x7ffeb33c15a8, init=<optimised out>, fini=<optimised out>, rtld_fini=<optimised out>, stack_end=0x7ffeb33c1598) at ../csu/libc-start.c:310
        result = <optimised out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {0, -3021662798714391275, 94473280366544, 140731905480096, 0, 0, -9064321723719109355, -9044154686778395371}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x7fda73167733 <_dl_init+259>, 0x7fda731231f8}, data = {prev = 0x0, cleanup = 0x0, canceltype = 1930852147}}}
        not_first_call = <optimised out>
#43 0x000055ec465127fa in _start ()
gdb returned 0
Aborted
gioman commented 4 years ago

("slope@1" > (6.94*0.85+((max("slope@1")-min("slope@1")))/4))*1

@JanChytry please attach sample data.

janchytry commented 4 years ago

Of course, sorry, here it is: slope.zip

gioman commented 4 years ago

Confirmed on the same platform and as well on Windows.

pblottiere commented 4 years ago

Confirmed on Archlinux, I take a look.

pblottiere commented 4 years ago

Hi @JanChytry,

Actually, the min and max functions in the raster calculator need two rasters in parameter, but the dialog window was allowing you to use only one parameter, leading to a segmentation fault.

It has been fixed on master with https://github.com/qgis/QGIS/pull/37273.

But unfortunately, you won't be able to use the ("slope@1" > (6.94*0.85+((max("slope@1")-min("slope@1")))/4))*1 expression.

gioman commented 4 years ago

It has been fixed on master with #37273.

@pblottiere so we should close this, correct?

But unfortunately, you won't be able to use the ("slope@1" > (6.94*0.85+((max("slope@1")-min("slope@1")))/4))*1 expression.

why?

pblottiere commented 4 years ago

so we should close this, correct?

Yes the segfault is fixed.

why?

Because the min/max functions don't return the minimum/maximum value within a band, but it seems that's what @JanChytry would like to do.

gioman commented 4 years ago

don't return the minimum/maximum value within a band

hummm from a user point of view is a bit counter intuitive, what that functions return then?

luipir commented 4 years ago

hummm from a user point of view is a bit counter intuitive, what that functions return then?

them min or max pixel by pixel between two rasters but not the absolute min or max for a band. Min and Max are (now explicitly) binary operators