MRtrix3 / mrtrix3

MRtrix3 provides a set of tools to perform various advanced diffusion MRI analyses, including constrained spherical deconvolution (CSD), probabilistic tractography, track-density imaging, and apparent fibre density
http://www.mrtrix.org
Mozilla Public License 2.0
293 stars 180 forks source link

mrview segfault with -overlay.load #1506

Open Lestropie opened 5 years ago

Lestropie commented 5 years ago

Have hit this one a few times, but always when madly trying to put figures together, so have never pursued it.

Occurs for both 3D and 4D overlay images. Either case works fine if the overlay is loaded from the GUI rather than the command-line.

My suspicion is that there's a code path whereby something is trying to access the value of some element of the overlay toolbar, but use of command-line options related to toolbars when executing mrview does not in fact open those toolbars, and hence that element is uninitialised. Unfortunately the traceback is not overly helpful even with QT debugging symbols installed.

Appears to not be the same as #871.

The progress bar for loading the overlay image into memory appears, gets to 100%, and closes, before the segfault occurs.

Starting program: /home/rob/src/mrtrix3/bin/mrview anat/t1.mif -overlay.load parc/nodes_fix_RGB.mif
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7fffe7b70700 (LWP 13422)]
[New Thread 0x7fffdd8c6700 (LWP 13423)]
[New Thread 0x7fffdd0c5700 (LWP 13424)]
[New Thread 0x7fffd7591700 (LWP 13426)]

Thread 1 "mrview" received signal SIGSEGV, Segmentation fault.
0x00007ffff57048d7 in QVariantAnimationPrivate::valueAt(double) const () at ../../include/QtCore/../../src/corelib/tools/qpair.h:148
148 ../../include/QtCore/../../src/corelib/tools/qpair.h: No such file or directory.
(gdb) bt
#0  0x00007ffff57048d7 in QVariantAnimationPrivate::valueAt(double) const (this=0x6e6f6974, step=0) at ../../include/QtCore/../../src/corelib/tools/qpair.h:148
#1  0x00007ffff5705411 in QVariantAnimation::keyValueAt(double) const (this=this@entry=0x555556b2db00, step=step@entry=0) at global/qglobal.h:1019
#2  0x00007ffff5705452 in QVariantAnimation::startValue() const (this=this@entry=0x555556b2db00) at animation/qvariantanimation.cpp:538
#3  0x00007ffff5708c7f in QPropertyAnimation::updateState(QAbstractAnimation::State, QAbstractAnimation::State) (this=0x555556b2db00, newState=<optimized out>, oldState=QAbstractAnimation::Stopped)
    at animation/qpropertyanimation.cpp:289
#4  0x00007ffff5702abc in QAbstractAnimationPrivate::setState(QAbstractAnimation::State) (newState=QAbstractAnimation::Running, this=0x555556b3cc60)
    at ../../include/QtCore/../../src/corelib/tools/qsharedpointer_impl.h:167
#5  0x00007ffff5702abc in QAbstractAnimation::start(QAbstractAnimation::DeletionPolicy) (this=<optimized out>, policy=<optimized out>) at animation/qabstractanimation.cpp:1367
#6  0x00007ffff672e477 in QWidgetAnimator::animate(QWidget*, QRect const&, bool) (this=this@entry=0x55555626bc60, widget=<optimized out>, _final_geometry=..., animate=<optimized out>, animate@entry=false)
    at widgets/qwidgetanimator.cpp:107
#7  0x00007ffff676deb1 in QDockAreaLayout::apply(bool) (this=this@entry=0x55555626b800, animate=animate@entry=false) at widgets/qdockarealayout.cpp:3221
#8  0x00007ffff679e432 in QMainWindowLayoutState::apply(bool) (animated=<optimized out>, this=0x55555626b728) at widgets/qmainwindowlayout.cpp:653
#9  0x00007ffff679e432 in QMainWindowLayout::applyState(QMainWindowLayoutState&, bool) (this=this@entry=0x55555626b6c0, newState=..., animate=animate@entry=false) at widgets/qmainwindowlayout.cpp:2681
#10 0x00007ffff67a1b12 in QMainWindowLayout::setGeometry(QRect const&) (this=0x55555626b6c0, _r=...) at widgets/qmainwindowlayout.cpp:1938
#11 0x00007ffff6659dd8 in QLayoutPrivate::doResize(QSize const&) (this=this@entry=0x555556275d50, r=...) at ../../include/QtCore/../../src/corelib/tools/qrect.h:184
#12 0x00007ffff665aec6 in QLayout::activate() (this=<optimized out>) at ../../include/QtCore/../../src/corelib/tools/qsize.h:119
#13 0x00007ffff665b0cc in QLayout::widgetEvent(QEvent*) (this=<optimized out>, e=e@entry=0x555556b4a7d0) at kernel/qlayout.cpp:615
#14 0x00007ffff663d4c8 in QApplicationPrivate::notify_helper(QObject*, QEvent*) (this=this@entry=0x5555560b4e80, receiver=receiver@entry=0x7fffffffd150, e=e@entry=0x555556b4a7d0) at kernel/qapplication.cpp:3723
#15 0x00007ffff664500b in QApplication::notify(QObject*, QEvent*) (this=0x5555560b74c0, receiver=0x7fffffffd150, e=0x555556b4a7d0) at kernel/qapplication.cpp:3491
#16 0x00007ffff58f5e59 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (receiver=0x7fffffffd150, event=0x555556b4a7d0) at ../../include/QtCore/../../src/corelib/kernel/qobject.h:148
#17 0x00007ffff58f893c in QCoreApplication::sendEvent(QObject*, QEvent*) (event=0x555556b4a7d0, receiver=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:234
#18 0x00007ffff58f893c in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) (receiver=0x0, event_type=0, data=0x5555560b6380) at kernel/qcoreapplication.cpp:1740
#19 0x00007ffff58f8dba in QCoreApplication::sendPostedEvents(QObject*, int) (receiver=receiver@entry=0x0, event_type=event_type@entry=0) at kernel/qcoreapplication.cpp:1594
#20 0x00007ffff5949ca4 in postEventSourceDispatch(GSource*, GSourceFunc, gpointer) (s=0x5555562e0b60) at kernel/qeventdispatcher_glib.cpp:276
#21 0x00007ffff08f1368 in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#22 0x00007ffff08f15b1 in  () at /usr/lib/libglib-2.0.so.0
---Type <return> to continue, or q <return> to quit---
#23 0x00007ffff08f163e in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#24 0x00007ffff5949249 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x55555620d2d0, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#25 0x00007fffeb0899f2 in QPAEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x55555620d2d0, flags=...) at qeventdispatcher_glib.cpp:69
#26 0x00007ffff58f496c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x7fffffffd070, flags=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:140
#27 0x00007ffff58fcf16 in QCoreApplication::exec() () at ../../include/QtCore/../../src/corelib/global/qflags.h:120
#28 0x0000555555b6654e in run() () at cmd/mrview.cpp:99
#29 0x0000555555b660dc in main(int, char**) (cmdline_argc=4, cmdline_argv=0x7fffffffe208) at ./core/command.h:97
daljit46 commented 6 months ago

I'm not sure if this can still be reproduced (I think someone on the forum reported something somewhat related), but I think this is potentially a consequence of relying on qApp->processEvents(). From the Qt's documentation:

Use of this function is discouraged. Instead, prefer to move long operations out of the GUI thread into an auxiliary one and to completely avoid nested event loop processing. If event processing is really necessary, consider using QEventLoop instead.

jdtournier commented 6 months ago

Is this the same issue as discussed on the forum recently? I've looked into it, and I couldn't see a simple fix. That progressbar is a real problem...

In the meantime, the simplest way around it is to add the -quiet option to your mrview command, which prevents the progressbar from showing at all...

daljit46 commented 6 months ago

After looking around, I'm quite confident this is the same issue. I found this issue and another one that look very similar to this problem. I think we should try to find a strategy that completely avoids calling QCoreApplication::processEvents, which seems to be the culprit.