bugGNU Octave - Bugs: bug #54369, [MXE-Octave] crash on...

 
 

bug #54369: [MXE-Octave] crash on "__octave_link_gui_preference__"

Submitter:  Markus Mützel <mmuetzel>
Submitted:  Tue 24 Jul 2018 10:24:43 PM UTC
   
 
Category:  GUI Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Fixed Assigned to:  ttl
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 27 Jul 2018 12:02:55 PM UTC, comment #4: 

Thanks for the quick fix. I tested on Windows 10 and it also no longer segfaults for me.

Closing as fixed.

Markus Mützel <mmuetzel>
Group administrator
Thu 26 Jul 2018 06:21:10 PM UTC, comment #3: 

I have pushed cset
http://hg.savannah.gnu.org/hgweb/octave/rev/3418d3729a51
wchih fixes the bug on windows 8 for me.

Torsten Lilge <ttl>
Group Member
Wed 25 Jul 2018 06:38:58 PM UTC, comment #2: 

Markus, thanks for debugging.

I stumbled about the same sentence in the docs. The unlock was to make sure that the lock is really unlocked, a habit I have taken some time ago while programming for a certain real-time operation system. I am currently thinking about just dropping this unlock or using the mutex that already exists in octave_qt_link (knowing this mechanism works).

Torsten Lilge <ttl>
Group Member
Wed 25 Jul 2018 06:29:30 PM UTC, comment #1: 

With debug symbols, I get the following backtrace:

(gdb) continue
Continuing.
[Thread 17316.0x1d0 exited with code 0]

Thread 13 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 17316.0x46d8]
0x000000000d40f1a2 in QBasicMutex::unlockInternal() ()
   from D:\Repositories\Octave\test\octave-2018-07-25-19-17-w64_debug\octave-2018-07-25-19-17-w64\bin\Qt5Core.dll
(gdb) bt
#0  0x000000000d40f1a2 in QBasicMutex::unlockInternal() ()
   from D:\Repositories\Octave\test\octave-2018-07-25-19-17-w64_debug\octave-2018-07-25-19-17-w64\bin\Qt5Core.dll
#1  0x0000000064f16df6 in octave::octave_qt_link::do_gui_preference (this=0x3deb2730, key=..., value=...)
    at /home/osboxes/Documents/Repositories/Octave/mxe-octave-3/tmp-default-octave/octave-5.0.0/libgui/src/octave-qt-link.cc:588
#2  0x000000000e9f3865 in octave_link::gui_preference (value=..., key=...)
    at /home/osboxes/Documents/Repositories/Octave/mxe-octave-3/tmp-default-octave/octave-5.0.0/libinterp/corefcn/octave-link.h:377
#3  F__octave_link_gui_preference__ (args=...)
    at /home/osboxes/Documents/Repositories/Octave/mxe-octave-3/tmp-default-octave/octave-5.0.0/libinterp/corefcn/octave-link.cc:403
#4  0x000000000e5c69ff in octave_builtin::call (this=0x410366c0, tw=..., nargout=1, args=...)
    at /home/osboxes/Documents/Repositories/Octave/mxe-octave-3/tmp-default-octave/octave-5.0.0/libinterp/octave-value/ov-builtin.cc:65
#5  0x000000000e6d447a in octave::tree_evaluator::visit_index_expression (this=0x40c20b90, idx_expr=...)
    at /home/osboxes/Documents/Repositories/Octave/mxe-octave-3/tmp-default-octave/octave-5.0.0/libinterp/parse-tree/pt-eval.cc:1875
#6  0x000000000ec16d76 in octave::tree_evaluator::evaluate (this=0x40c20b90, expr=0x3debb6f0, nargout=<optimized out>)
    at /home/osboxes/Documents/Repositories/Octave/mxe-octave-3/tmp-default-octave/octave-5.0.0/libinterp/parse-tree/pt-eval.h:302
#7  0x000000000e6d5875 in octave::tree_evaluator::visit_simple_assignment (this=0x40c20b90, expr=...)
    at /home/osboxes/Documents/Repositories/Octave/mxe-octave-3/tmp-default-octave/octave-5.0.0/libinterp/parse-tree/pt-eval.cc:2528
#8  0x000000000ec16d76 in octave::tree_evaluator::evaluate (this=0x40c20b90, expr=0x3dde0b20, nargout=<optimized out>)
    at /home/osboxes/Documents/Repositories/Octave/mxe-octave-3/tmp-default-octave/octave-5.0.0/libinterp/parse-tree/pt-eval.h:302
#9  0x000000000e6d161d in octave::tree_evaluator::visit_statement (this=0x40c20b90, stmt=...)
    at /home/osboxes/Documents/Repositories/Octave/mxe-octave-3/tmp-default-octave/octave-5.0.0/libinterp/parse-tree/pt-eval.cc:2642
#10 0x000000000e6c78fb in octave::tree_statement::accept (tw=..., this=0x3dde0a20)
    at /home/osboxes/Documents/Repositories/Octave/mxe-octave-3/tmp-default-octave/octave-5.0.0/libinterp/parse-tree/pt-stmt.h:115
#11 octave::tree_evaluator::visit_statement_list (this=0x40c20b90, lst=...)
    at /home/osboxes/Documents/Repositories/Octave/mxe-octave-3/tmp-default-octave/octave-5.0.0/libinterp/parse-tree/pt-eval.cc:2711
#12 0x000000000e6cad4a in octave::tree_statement_list::accept (tw=..., this=<optimized out>)
    at /home/osboxes/Documents/Repositories/Octave/mxe-octave-3/tmp-default-octave/octave-5.0.0/libinterp/parse-tree/pt-stmt.h:190
#13 octave::tree_evaluator::repl (this=this@entry=0x40c20b90, interactive=true)
    at /home/osboxes/Documents/Repositories/Octave/mxe-octave-3/tmp-default-octave/octave-5.0.0/libinterp/parse-tree/pt-eval.cc:105
#14 0x000000000e92e64e in octave::interpreter::main_loop (this=this@entry=0x40c20040)
---Type <return> to continue, or q <return> to quit---
    at /home/osboxes/Documents/Repositories/Octave/mxe-octave-3/tmp-default-octave/octave-5.0.0/libinterp/corefcn/interpreter.cc:949
#15 0x000000000e936ada in octave::interpreter::main_loop (this=0x40c20040)
    at /home/osboxes/Documents/Repositories/Octave/mxe-octave-3/tmp-default-octave/octave-5.0.0/libinterp/corefcn/interpreter.cc:932
#16 octave::interpreter::execute (this=this@entry=0x40c20040)
    at /home/osboxes/Documents/Repositories/Octave/mxe-octave-3/tmp-default-octave/octave-5.0.0/libinterp/corefcn/interpreter.cc:694
#17 0x0000000064f090f6 in octave::octave_interpreter::execute (this=0x375d65f0)
    at /home/osboxes/Documents/Repositories/Octave/mxe-octave-3/tmp-default-octave/octave-5.0.0/libgui/src/main-window.cc:141
#18 0x0000000064f5e1a5 in octave::octave_interpreter::qt_static_metacall (_o=0x419bb530, _c=QMetaObject::RegisterMethodArgumentMetaType, _id=-1048576,
    _a=0x6b0d46 <Curl_ftp_parselist+950>) at libgui/src/moc-main-window.cc:89
#19 0x000000000d5f5d6a in QObject::event(QEvent*) ()
   from D:\Repositories\Octave\test\octave-2018-07-25-19-17-w64_debug\octave-2018-07-25-19-17-w64\bin\Qt5Core.dll
#20 0x000000000d967c5c in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
   from D:\Repositories\Octave\test\octave-2018-07-25-19-17-w64_debug\octave-2018-07-25-19-17-w64\bin\Qt5Widgets.dll
#21 0x000000000d96ede0 in QApplication::notify(QObject*, QEvent*) ()
   from D:\Repositories\Octave\test\octave-2018-07-25-19-17-w64_debug\octave-2018-07-25-19-17-w64\bin\Qt5Widgets.dll
#22 0x000000000d5c9e38 in QCoreApplication::notifyInternal2(QObject*, QEvent*) ()
   from D:\Repositories\Octave\test\octave-2018-07-25-19-17-w64_debug\octave-2018-07-25-19-17-w64\bin\Qt5Core.dll
#23 0x000000000d5d0089 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) ()
   from D:\Repositories\Octave\test\octave-2018-07-25-19-17-w64_debug\octave-2018-07-25-19-17-w64\bin\Qt5Core.dll
#24 0x000000000d6220e8 in QEventDispatcherWin32Private::sendTimerEvent(int) ()
   from D:\Repositories\Octave\test\octave-2018-07-25-19-17-w64_debug\octave-2018-07-25-19-17-w64\bin\Qt5Core.dll
#25 0x00007ffd13d36cc1 in USER32!CallWindowProcW () from C:\WINDOWS\System32\user32.dll
#26 0x00007ffd13d36693 in USER32!DispatchMessageW () from C:\WINDOWS\System32\user32.dll
#27 0x000000000d62183b in QEventDispatcherWin32::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from D:\Repositories\Octave\test\octave-2018-07-25-19-17-w64_debug\octave-2018-07-25-19-17-w64\bin\Qt5Core.dll
#28 0x000000000d5c86ff in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from D:\Repositories\Octave\test\octave-2018-07-25-19-17-w64_debug\octave-2018-07-25-19-17-w64\bin\Qt5Core.dll
#29 0x000000000d413c19 in QThread::run() ()
   from D:\Repositories\Octave\test\octave-2018-07-25-19-17-w64_debug\octave-2018-07-25-19-17-w64\bin\Qt5Core.dll
---Type <return> to continue, or q <return> to quit---
#30 0x000000000d41ea17 in QtPrivate::ResultStoreBase::addResults(int, void const*, int, int) ()
   from D:\Repositories\Octave\test\octave-2018-07-25-19-17-w64_debug\octave-2018-07-25-19-17-w64\bin\Qt5Core.dll
#31 0x00007ffd15ea3034 in KERNEL32!BaseThreadInitThunk () from C:\WINDOWS\System32\kernel32.dll
#32 0x00007ffd16091431 in ntdll!RtlUserThreadStart () from C:\WINDOWS\SYSTEM32\ntdll.dll
#33 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb)



That means it segfault on the unlock here:

  std::string octave_qt_link::do_gui_preference (const std::string& key,
                                                 const std::string& value)
  {
    QMutex wait_for_gui;
    QString pref_value;

    // Emit the signal for changing or getting a preference
    emit gui_preference_signal (QString::fromStdString (key),
                                QString::fromStdString (value),
                                &wait_for_gui, &pref_value);

    // Unlock and lock the mutex (make sure it is locked without being blocked)
    wait_for_gui.unlock ();
    wait_for_gui.lock ();

    // Try to lock it again, thus waiting for the unlock of the gui after
    // reading/changing desired preference. A timeout of 3 s for not being
    // blocked forever if something goes wrong
    wait_for_gui.tryLock (3000);

    return pref_value.toStdString ();
  }


I don't know why it is tried to unlock the thread before it is locked in the next line. And locked again (?) with the next command.
The Qt manual for "unlock" [1] reads: "Unlocking a mutex that is not locked results in undefined behavior."
So we should probably try and avoid that.

[1]: http://doc.qt.io/qt-5/qmutex.html

Markus Mützel <mmuetzel>
Group administrator
Tue 24 Jul 2018 10:24:43 PM UTC, original submission:  

With a Windows cross-build of a recent tip (hg id 4de7535ece11), I get a segmentation fault on the following command:

orig_show_dbg = __octave_link_gui_preference__ ("editor/show_dbg_file", "0");


Attaching to gdb gives the following traceback:

[Thread 10384.0x2c0c exited with code 0]

Thread 9 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 10384.0x1a18]
0x000000006675f1a2 in QBasicMutex::unlockInternal() ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\Qt5Core.dll
(gdb) bt
#0  0x000000006675f1a2 in QBasicMutex::unlockInternal() ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\Qt5Core.dll
#1  0x0000000064f16df6 in liboctgui-3!_ZN6octave14octave_qt_link17do_gui_preferenceERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_ ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\liboctgui-3.dll
#2  0x0000000067853865 in liboctinterp-5!_Z31F__octave_link_gui_preference__RK17octave_value_listi ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\liboctinterp-5.dll
#3  0x00000000674269ff in liboctinterp-5!_ZN14octave_builtin4callERN6octave14tree_evaluatorEiRK17octave_value_list ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\liboctinterp-5.dll
#4  0x000000006753447a in liboctinterp-5!_ZN6octave14tree_evaluator22visit_index_expressionERNS_21tree_index_expressionE ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\liboctinterp-5.dll
#5  0x0000000067a76d76 in liboctinterp-5!_ZN6octave14tree_evaluator8evaluateEPNS_15tree_expressionEi ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\liboctinterp-5.dll
#6  0x0000000067535875 in liboctinterp-5!_ZN6octave14tree_evaluator23visit_simple_assignmentERNS_22tree_simple_assignmentE ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\liboctinterp-5.dll
#7  0x0000000067a76d76 in liboctinterp-5!_ZN6octave14tree_evaluator8evaluateEPNS_15tree_expressionEi ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\liboctinterp-5.dll
#8  0x000000006753161d in liboctinterp-5!_ZN6octave14tree_evaluator15visit_statementERNS_14tree_statementE ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\liboctinterp-5.dll
---Type <return> to continue, or q <return> to quit---
#9  0x00000000675278fb in liboctinterp-5!_ZN6octave14tree_evaluator20visit_statement_listERNS_19tree_statement_listE
    ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\liboctinterp-5.dll
#10 0x000000006752ad4a in liboctinterp-5!_ZN6octave14tree_evaluator4replEb ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\liboctinterp-5.dll
#11 0x0000000067796ada in liboctinterp-5!_ZN6octave11interpreter7executeEv ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\liboctinterp-5.dll
#12 0x0000000064f090f6 in liboctgui-3!_ZN6octave18octave_interpreter7executeEv ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\liboctgui-3.dll
#13 0x0000000064f5e1a5 in liboctgui-3!_ZN6octave18octave_interpreter18qt_static_metacallEP7QObjectN11QMetaObject4CallEiPPv ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\liboctgui-3.dll
#14 0x0000000066945d6a in QObject::event(QEvent*) ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\Qt5Core.dll
#15 0x0000000002077c5c in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\Qt5Widgets.dll
#16 0x000000000207ede0 in QApplication::notify(QObject*, QEvent*) ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\Qt5Widgets.dll
#17 0x0000000066919e38 in QCoreApplication::notifyInternal2(QObject*, QEvent*) ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\Qt5Core.dll
#18 0x0000000066920089 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\Qt5Core.dll
---Type <return> to continue, or q <return> to quit---
#19 0x00000000669720e8 in QEventDispatcherWin32Private::sendTimerEvent(int) ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\Qt5Core.dll
#20 0x00007ffd13d36cc1 in USER32!CallWindowProcW () from C:\WINDOWS\System32\user32.dll
#21 0x00007ffd13d36693 in USER32!DispatchMessageW () from C:\WINDOWS\System32\user32.dll
#22 0x000000006697183b in QEventDispatcherWin32::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\Qt5Core.dll
#23 0x00000000669186ff in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\Qt5Core.dll
#24 0x0000000066763c19 in QThread::run() ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\Qt5Core.dll
#25 0x000000006676ea17 in QtPrivate::ResultStoreBase::addResults(int, void const*, int, int) ()
   from D:\Repositories\Octave\test\octave-2018-07-24-21-12-w64_hdf5create\octave-2018-07-24-21-12-w64\bin\Qt5Core.dll
#26 0x00007ffd15ea3034 in KERNEL32!BaseThreadInitThunk () from C:\WINDOWS\System32\kernel32.dll
#27 0x00007ffd16091431 in ntdll!RtlUserThreadStart () from C:\WINDOWS\SYSTEM32\ntdll.dll
#28 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb)


Assigning to Torsten since he recently added this function.
Can I do anything to help debugging? Should I recompile with symbols to get a more verbose backtrace? (Might take a while)

Markus Mützel <mmuetzel>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by ttl (Posted a comment)
  • -email is unavailable- added by mmuetzel (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-07-27 mmuetzel StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2018-07-26 ttl StatusNone Ready For Test

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code