bugGNU Octave - Bugs: bug #63180, Octave crashes opening a GUI with...

 
 

bug #63180: Octave crashes opening a GUI with an indexed object and menu with callback

Submitter:  Richard Stephens <ristephens>
Submitted:  Fri 07 Oct 2022 01:07:48 PM UTC
 
Category:  GUI Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Confirmed Assigned to:  None
Originator Name:  Richard Stephens Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

Mon 28 Nov 2022 03:21:17 PM UTC, comment #4: 

was looking through classdef related bugs to see if they should get Categorized as such. @Markus, from your debugging is traced back to a classdef issue, or is the gui category best?

Nicholas Jankowski <nrjank>
Project Member
Fri 07 Oct 2022 05:21:30 PM UTC, comment #3: 

On Linux at hg id 6cf7dab21e9b, the GUI doesn't crash. But it deadlocked with one CPU at 100% load until I killed the process.

Markus Mützel <mmuetzel>
Project Member
Fri 07 Oct 2022 04:51:46 PM UTC, comment #2: 

Same with a current build (not stripped) from the default branch (hg id 6cf7dab21e9b) on Windows.

Thread 31 hit Breakpoint 1, 0x00007ff9f3c82547 in msvcrt!abort () from C:\WINDOWS\System32\msvcrt.dll
(gdb) bt
#0  0x00007ff9f3c82547 in msvcrt!abort () from C:\WINDOWS\System32\msvcrt.dll
#1  0x00007ff99efd2b56 in ?? () from C:\msys64\mingw64\bin\libstdc++-6.dll
#2  0x00007ff99efc5706 in ?? () from C:\msys64\mingw64\bin\libstdc++-6.dll
#3  0x00007ff99f0cad83 in ?? () from C:\msys64\mingw64\bin\libstdc++-6.dll
#4  0x00007ff99efc5c59 in ?? () from C:\msys64\mingw64\bin\libstdc++-6.dll
#5  0x00007ff9eb56275d in ?? () from C:\msys64\mingw64\bin\libgcc_s_seh-1.dll
#6  0x00007ff99f0cbbc5 in ?? () from C:\msys64\mingw64\bin\libstdc++-6.dll
#7  0x00007ff9f58b3e1f in ntdll!.chkstk () from C:\WINDOWS\SYSTEM32\ntdll.dll
#8  0x00007ff9f582eae6 in ntdll!RtlFindCharInUnicodeString () from C:\WINDOWS\SYSTEM32\ntdll.dll
#9  0x00007ff9f58b2e0e in ntdll!KiUserExceptionDispatcher () from C:\WINDOWS\SYSTEM32\ntdll.dll
#10 0x00007ff9f2dffaec in RaiseException () from C:\WINDOWS\System32\KernelBase.dll
#11 0x00007ff9eb562811 in ?? () from C:\msys64\mingw64\bin\libgcc_s_seh-1.dll
#12 0x00007ff99f0cb379 in ?? () from C:\msys64\mingw64\bin\libstdc++-6.dll
#13 0x00007ff906ff4d07 in octave::error_system::throw_error (this=this@entry=0x1c8088f9a48, ex=...) at ../libinterp/corefcn/error.cc:890
#14 0x00007ff906a0234d in octave::error_system::throw_error (this=this@entry=0x1c8088f9a48, err_type="error", id="",
    message="break_closure_cycles: invalid object", stack_info_arg=empty std::__cxx11::list) at ../libinterp/corefcn/error.cc:885
#15 0x00007ff906a02600 in octave::error_system::error_1 (this=0x1c8088f9a48, id=<optimized out>, fmt=<optimized out>, args=<optimized out>)
    at ../libinterp/corefcn/error.cc:580
#16 0x00007ff906a02666 in error_1 (
    id=0x7ff90707d7e7 <typeinfo name for std::_Bind<octave::Fdlmread(octave::interpreter&, octave_value_list const&, int)::{lambda()#1} ()>+9639> "",
    fmt=0x7ff9070220f5 "%s: invalid object", args=0x9b72ffbaf8 "¥!\002\aù\177") at ../libinterp/corefcn/error.cc:90
#17 0x00007ff906a02686 in verror (fmt=0x1 <error: Cannot access memory at address 0x1>, args=0x7ff9f3cee7a0 "P\vø\vÈ\001")
    at ../libinterp/corefcn/error.cc:975
#18 0x00007ff906a026b2 in error (fmt=0x1c88012e8b0 "à}\f\aù\177") at ../libinterp/corefcn/error.cc:983
#19 0x00007ff906e9c4f7 in octave::cdef_object_rep::err_invalid_object (who=0x7ff9070221a5 "break_closure_cycles", this=<optimized out>)
    at ../libinterp/octave-value/cdef-object.h:197
#20 octave::cdef_object_rep::break_closure_cycles (this=<optimized out>) at ../libinterp/octave-value/cdef-object.h:123
#21 0x00007ff906d1675f in octave::user_fcn_stack_frame::break_closure_cycles (this=0x1c809cfa7e0,
    frame=std::shared_ptr<octave::stack_frame> (use count 3, weak count 0) = {...}) at ../libinterp/corefcn/stack-frame.cc:2375
#22 0x00007ff906948177 in octave::call_stack::pop (this=0x1c8088fa890) at ../libinterp/corefcn/call-stack.cc:769
#23 0x00007ff906807ef7 in std::function<void ()>::operator()() const (this=0x9b72ffbbf0)
    at C:/msys64/mingw64/include/c++/12.2.0/bits/std_function.h:587
#24 octave::unwind_action::run (this=0x9b72ffbbf0) at ../liboctave/util/unwind-prot.h:204
#25 octave::unwind_action::~unwind_action (this=0x9b72ffbbf0, __in_chrg=<optimized out>) at ../liboctave/util/unwind-prot.h:185
#26 octave_user_function::call (this=this@entry=0x1c809f2c3a0, tw=..., nargout=nargout@entry=0, args=...)
    at ../libinterp/octave-value/ov-usr-fcn.cc:488
#27 0x00007ff9068ad6fa in octave::tree_identifier::evaluate_n (this=<optimized out>, tw=..., nargout=0) at ../libinterp/parse-tree/pt-id.cc:130
#28 0x00007ff906ea245a in octave::tree_identifier::evaluate (this=<optimized out>, tw=..., nargout=<optimized out>)
    at ../libinterp/parse-tree/pt-id.h:98
#29 0x00007ff9068a3ee6 in octave::tree_evaluator::visit_statement (this=0x1c8088fa768, stmt=...) at ../libinterp/parse-tree/pt-eval.cc:3940
#30 0x00007ff90688fe1b in octave::tree_statement::accept (tw=..., this=0x1c881228f60) at ../libinterp/parse-tree/pt-stmt.h:124
#31 octave::tree_evaluator::visit_statement_list (this=0x1c8088fa768, lst=...) at ../libinterp/parse-tree/pt-eval.cc:4025
#32 0x00007ff9068927a8 in octave::tree_statement_list::accept (tw=..., this=<optimized out>) at ../libinterp/parse-tree/pt-stmt.h:201
#33 octave::tree_evaluator::eval (this=0x1c8088fa768, stmt_list=..., interactive=<optimized out>) at ../libinterp/parse-tree/pt-eval.cc:985
--Type <RET> for more, q to quit, c to continue without paging--c
#34 0x00007ff9068a00b1 in octave::tree_evaluator::repl (this=this@entry=0x1c8088fa768) at ../libinterp/parse-tree/pt-eval.cc:804
#35 0x00007ff906bb13a1 in octave::interpreter::main_loop (this=0x1c8088f9940) at ../libinterp/corefcn/interpreter.cc:1350
#36 octave::interpreter::execute (this=this@entry=0x1c8088f9940) at ../libinterp/corefcn/interpreter.cc:916
#37 0x00007ff94da59561 in octave::interpreter_qobject::execute (this=0x1c80db14480) at ../libgui/src/interpreter-qobject.cc:89
#38 0x00007ff9938c166b in QObject::event(QEvent*) () from C:\msys64\mingw64\bin\Qt5Core.dll
#39 0x00007ff98d9c7bfe in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from C:\msys64\mingw64\bin\Qt5Widgets.dll
#40 0x00007ff94dab6343 in octave::octave_qapplication::notify (this=0x1c80dabc070, receiver=<optimized out>, ev=<optimized out>) at ../libgui/src/octave-qobject.cc:148
#41 0x00007ff993894ef8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from C:\msys64\mingw64\bin\Qt5Core.dll
#42 0x00007ff99389b298 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from C:\msys64\mingw64\bin\Qt5Core.dll
#43 0x00007ff9938ef20c in QEventDispatcherWin32::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from C:\msys64\mingw64\bin\Qt5Core.dll
#44 0x00007ff993893ad3 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from C:\msys64\mingw64\bin\Qt5Core.dll
#45 0x00007ff9936c9751 in QThread::run() () from C:\msys64\mingw64\bin\Qt5Core.dll
#46 0x00007ff9936ca38d in QThreadPrivate::start(void*) () from C:\msys64\mingw64\bin\Qt5Core.dll
#47 0x00007ff9f469244d in KERNEL32!BaseThreadInitThunk () from C:\WINDOWS\System32\kernel32.dll
#48 0x00007ff9f586df78 in ntdll!RtlUserThreadStart () from C:\WINDOWS\SYSTEM32\ntdll.dll
#49 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb)

Really, looks like an invalid classdef object from somewhere.

CC'ing jwe since he is the only one who has a decent understanding of the classdef code afaict.

Markus Mützel <mmuetzel>
Project Member
Fri 07 Oct 2022 04:20:21 PM UTC, comment #1: 

Confirmed here with Octave 7.2.0 on Windows.

Executing `myGui` closes Octave unexpectedly.
`gdb` doesn't catch anything. All threads and the entire process just exit with code 3. No backtrace.

I then attached `gdb`, set a breakpoint in `abort`, and executed the function again.
With that, I got this backtrace:

Thread 25 hit Breakpoint 1, 0x00007ff9f3c82547 in msvcrt!abort () from C:\WINDOWS\System32\msvcrt.dll
(gdb) bt
#0  0x00007ff9f3c82547 in msvcrt!abort () from C:\WINDOWS\System32\msvcrt.dll
#1  0x000000006fc6146a in libstdc++-6!_ZN9__gnu_cxx27__verbose_terminate_handlerEv ()
   from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\libstdc++-6.dll
#2  0x000000006fc57a66 in libstdc++-6!_ZGTtNKSt9exceptionD1Ev ()
   from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\libstdc++-6.dll
#3  0x000000006fd522e3 in libstdc++-6!.cxa_begin_catch ()
   from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\libstdc++-6.dll
#4  0x000000006fc57ddc in libstdc++-6!_ZN10__cxxabiv129__pointer_to_member_type_infoD2Ev ()
   from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\libstdc++-6.dll
#5  0x000000006144d075 in libgcc_s_seh-1!_GCC_specific_handler ()
   from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\libgcc_s_seh-1.dll
#6  0x000000006fd532c5 in libstdc++-6!.gxx_personality_seh0 ()
   from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\libstdc++-6.dll
#7  0x00007ff9f58b3e1f in ntdll!.chkstk () from C:\WINDOWS\SYSTEM32\ntdll.dll
#8  0x00007ff9f582eae6 in ntdll!RtlFindCharInUnicodeString () from C:\WINDOWS\SYSTEM32\ntdll.dll
#9  0x00007ff9f58b2e0e in ntdll!KiUserExceptionDispatcher () from C:\WINDOWS\SYSTEM32\ntdll.dll
#10 0x00007ff9f2dffaec in RaiseException () from C:\WINDOWS\System32\KernelBase.dll
#11 0x000000006144d151 in libgcc_s_seh-1!_Unwind_RaiseException ()
   from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\libgcc_s_seh-1.dll
#12 0x000000006fd529eb in libstdc++-6!.cxa_throw () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\libstdc++-6.dll
#13 0x0000000066971fa9 in liboctinterp-10!_ZN6octave12error_system11throw_errorERNS_19execution_exceptionE ()
   from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\liboctinterp-10.dll
#14 0x000000006634cfef in liboctinterp-10!_ZN6octave12error_system11throw_errorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_S8_RKNS1_4listINS_10frame_infoESaISA_EEE ()
   from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\liboctinterp-10.dll
#15 0x000000006634d2ba in liboctinterp-10!_ZN6octave12error_system7error_1EPKcS2_Pc ()
   from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\liboctinterp-10.dll
#16 0x000000006634d34d in liboctinterp-10!_ZN6octave12error_system7error_1EPKcS2_Pc ()
   from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\liboctinterp-10.dll
--Type <RET> for more, q to quit, c to continue without paging--c
#17 0x000000006634d386 in liboctinterp-10!_Z6verrorPKcPc () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\liboctinterp-10.dll
#18 0x000000006634d3b2 in liboctinterp-10!_Z5errorPKcz () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\liboctinterp-10.dll
#19 0x00000000667f8647 in liboctinterp-10!_ZN6octave15cdef_object_rep20break_closure_cyclesERKSt10shared_ptrINS_11stack_frameEE () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\liboctinterp-10.dll
#20 0x000000006665e9cf in liboctinterp-10!_ZN6octave20user_fcn_stack_frame20break_closure_cyclesERKSt10shared_ptrINS_11stack_frameEE () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\liboctinterp-10.dll
#21 0x00000000662891ea in liboctinterp-10!_ZN6octave10call_stack3popEv () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\liboctinterp-10.dll
#22 0x0000000066170373 in liboctinterp-10!_ZN20octave_user_function4callERN6octave14tree_evaluatorEiRK17octave_value_list () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\liboctinterp-10.dll
#23 0x000000006620086d in liboctinterp-10!_ZN6octave15tree_identifier10evaluate_nERNS_14tree_evaluatorEi () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\liboctinterp-10.dll
#24 0x00000000667ff25c in liboctinterp-10!_ZN6octave15tree_identifier8evaluateERNS_14tree_evaluatorEi () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\liboctinterp-10.dll
#25 0x00000000661fb7cc in liboctinterp-10!_ZN6octave14tree_evaluator15visit_statementERNS_14tree_statementE () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\liboctinterp-10.dll
#26 0x00000000661e7cdc in liboctinterp-10!_ZN6octave14tree_evaluator20visit_statement_listERNS_19tree_statement_listE () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\liboctinterp-10.dll
#27 0x00000000661e97aa in liboctinterp-10!_ZN6octave14tree_evaluator4evalERSt10shared_ptrINS_19tree_statement_listEEb () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\liboctinterp-10.dll
#28 0x00000000661f761e in liboctinterp-10!_ZN6octave14tree_evaluator4replEv () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\liboctinterp-10.dll
#29 0x00000000664fd4f9 in liboctinterp-10!_ZN6octave11interpreter7executeEv () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\liboctinterp-10.dll
#30 0x0000000000f24670 in liboctgui-8!_ZN6octave19interpreter_qobject7executeEv () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\liboctgui-8.dll
#31 0x00000000052e17ec in QObject::event(QEvent*) () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\Qt5Core.dll
#32 0x0000000005e77e73 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\Qt5Widgets.dll
#33 0x0000000000f7fd26 in liboctgui-8!_ZN6octave19octave_qapplication6notifyEP7QObjectP6QEvent () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\liboctgui-8.dll
#34 0x00000000052b47ed in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\Qt5Core.dll
#35 0x00000000052ba93b in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\Qt5Core.dll
#36 0x000000000530f448 in QEventDispatcherWin32::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\Qt5Core.dll
#37 0x00000000052b3283 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\Qt5Core.dll
#38 0x00000000050e9140 in QThread::run() () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\Qt5Core.dll
#39 0x00000000050e9d45 in QThread::setTerminationEnabled(bool) () from C:\PROGRA~1\GNUOCT~1\OCTAVE~3.0\mingw64\bin\Qt5Core.dll
#40 0x00007ff9f469244d in KERNEL32!BaseThreadInitThunk () from C:\WINDOWS\System32\kernel32.dll
#41 0x00007ff9f586df78 in ntdll!RtlUserThreadStart () from C:\WINDOWS\SYSTEM32\ntdll.dll
#42 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

The last point in our code is `_ZN6octave12error_system11throw_errorERNS_19execution_exceptionE`. That demangles to
`octave::error_system::throw_error(octave::execution_exception&)`.

Are we missing to catch that exception somewhere?

Further down in the backtrace, it looks like the exception is caused somewhere in `octave::user_fcn_stack_frame::break_closure_cycles(std::shared_ptr<octave::stack_frame> const&)` that calls `octave::cdef_object_rep::break_closure_cycles(std::shared_ptr<octave::stack_frame> const&)`.
Maybe, this originates from an object array that is created with `obj(2) = myClass ();` in the function. Maybe, the element at `obj(1)` that should be implicitly created isn't handled correctly?

I'll try if I can reproduce with a build from the default branch or on Linux.

Markus Mützel <mmuetzel>
Project Member
Fri 07 Oct 2022 01:07:48 PM UTC, original submission:  

Octave crashes when creating a GUI that includes both of the following:

  • An indexed object instance of a classdef class.
  • A menu item that includes a callback to a nested function.

I've attached myGui.m and myClass.m as an example which crashes.

In myGui.m:

  • if you comment out the creation of the indexed object (line 11) it no longer crashes.
  • or if you comment out the callback from the menu item (line 18) it no longer crashes.
Richard Stephens <ristephens>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #53813:  myGui.m added by ristephens (730B - text/plain)
file #53814:  myClass.m added by ristephens (194B - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by mmuetzel
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by ristephens (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 project members can vote.

     

     

     

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-10-07 mmuetzel Release7.2.0 dev
        Operating SystemMicrosoft Windows Any
    2022-10-07 mmuetzel Carbon-Copy- Added jwe
    2022-10-07 mmuetzel Item GroupUnexpected Error or Warning Segfault, Bus Error, etc.
        StatusNone Confirmed
    2022-10-07 ristephens Attached File- Added myGui.m, #53813
        Attached File- Added myClass.m, #53814

    Back to the top


    Powered by Savane 3.9