bugGNU Octave - Bugs: bug #66659, Octave crashes with SIGSEGV when...

 
 

bug #66659: Octave crashes with SIGSEGV when debugging class methods

Submitter:  Torsten Lilge <ttl>
Submitted:  Mon 13 Jan 2025 07:13:16 PM UTC
   
 
Category:  Interpreter Severity:  4 - Important
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 16 Jan 2025 07:01:12 PM UTC, comment #4: 

This is what I see on MacOS:

Thread 0::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib                       0x19e6a6f54 mach_msg2_trap + 8
1   libsystem_kernel.dylib                       0x19e6b9604 mach_msg2_internal + 80
2   libsystem_kernel.dylib                       0x19e6afaf8 mach_msg_overwrite + 480
3   libsystem_kernel.dylib                       0x19e6a729c mach_msg + 24
4   CoreFoundation                               0x19e7d0a3c __CFRunLoopServiceMachPort + 160
5   CoreFoundation                               0x19e7cf29c __CFRunLoopRun + 1212
6   CoreFoundation                               0x19e7ce724 CFRunLoopRunSpecific + 588
7   HIToolbox                                    0x1a9d26530 RunCurrentEventLoopInMode + 292
8   HIToolbox                                    0x1a9d2c348 ReceiveNextEventCommon + 676
9   HIToolbox                                    0x1a9d2c508 _BlockUntilNextEventMatchingListInModeWithFilter + 76
10  AppKit                                       0x1a2339034 _DPSNextEvent + 660
11  AppKit                                       0x1a2c9d2d4 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 688
12  AppKit                                       0x1a232c060 -[NSApplication run] + 480
13  libqcocoa.dylib                              0x109d233f4 QCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 1932
14  QtCore                                       0x102b9b0c8 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 448
15  QtCore                                       0x102b94a24 QCoreApplication::exec() + 112
16  liboctgui.11.dylib                           0x1015ce30c octave::base_qobject::exec() + 28 (octave-qobject.cc:435)
17  liboctgui.11.dylib                           0x1015f786c octave::qt_application::execute() + 80 (qt-application.cc:104)
18  octave-gui                                   0x1003a263c main + 376 (main-gui.cc:168)
19  dyld                                         0x19e368274 start + 2840

Thread 1 Crashed:: QThread
0   liboctinterp.12.dylib                        0x104343aa8 octave::user_code_provider::user_code_provider(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, octave_user_code*, bool) + 224 (bp-table.cc:765)
1   liboctinterp.12.dylib                        0x10433b414 octave::user_code_provider::user_code_provider(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, octave_user_code*, bool) + 72 (bp-table.cc:763)
2   liboctinterp.12.dylib                        0x10433cd98 octave::bp_table::get_breakpoint_list(octave_value_list const&) + 560 (bp-table.cc:1248)
3   liboctinterp.12.dylib                        0x1045640d4 octave::Fdbstatus(octave::interpreter&, octave_value_list const&, int) + 528
4   liboctinterp.12.dylib                        0x1043e1ed8 octave::tree_evaluator::execute_builtin_function(octave_builtin&, int, octave_value_list const&) + 388 (pt-eval.cc:3554)
5   liboctinterp.12.dylib                        0x10422d694 octave_builtin::execute(octave::tree_evaluator&, int, octave_value_list const&) + 56 (ov-builtin.cc:49)
6   liboctinterp.12.dylib                        0x104297610 octave_function::call(octave::tree_evaluator&, int, octave_value_list const&) + 128 (ov-fcn.cc:74)
7   liboctinterp.12.dylib                        0x10442253c octave::tree_identifier::evaluate_n(octave::tree_evaluator&, int) + 696 (pt-id.cc:128)
8   liboctinterp.12.dylib                        0x104422acc octave::tree_identifier::evaluate(octave::tree_evaluator&, int) + 64 (pt-id.h:101)
9   liboctinterp.12.dylib                        0x1043e4454 octave::tree_evaluator::visit_statement(octave::tree_statement&) + 552 (pt-eval.cc:4072)
10  liboctinterp.12.dylib                        0x104439710 octave::tree_statement::accept(octave::tree_walker&) + 40 (pt-stmt.h:125)
11  liboctinterp.12.dylib                        0x1043e4b98 octave::tree_evaluator::visit_statement_list(octave::tree_statement_list&) + 180 (pt-eval.cc:4157)
12  liboctinterp.12.dylib                        0x104128590 octave::tree_statement_list::accept(octave::tree_walker&) + 40 (pt-stmt.h:215)
13  liboctinterp.12.dylib                        0x1043d38fc octave::debugger::repl(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) + 3096 (pt-eval.cc:475)
14  liboctinterp.12.dylib                        0x1043d8908 octave::tree_evaluator::enter_debugger(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) + 660 (pt-eval.cc:1453)
15  liboctinterp.12.dylib                        0x1043d839c octave::tree_evaluator::do_breakpoint(bool, bool) + 556 (pt-eval.cc:4660)
16  liboctinterp.12.dylib                        0x1043e4430 octave::tree_evaluator::visit_statement(octave::tree_statement&) + 516 (pt-eval.cc:4061)
17  liboctinterp.12.dylib                        0x104439710 octave::tree_statement::accept(octave::tree_walker&) + 40 (pt-stmt.h:125)
18  liboctinterp.12.dylib                        0x1043e4b98 octave::tree_evaluator::visit_statement_list(octave::tree_statement_list&) + 180 (pt-eval.cc:4157)
19  liboctinterp.12.dylib                        0x104128590 octave::tree_statement_list::accept(octave::tree_walker&) + 40 (pt-stmt.h:215)
20  liboctinterp.12.dylib                        0x1043e30ac octave::tree_evaluator::execute_user_function(octave_user_function&, int, octave_value_list const&) + 2472 (pt-eval.cc:3798)
21  liboctinterp.12.dylib                        0x1042f41a8 octave_user_function::execute(octave::tree_evaluator&, int, octave_value_list const&) + 56 (ov-usr-fcn.cc:569)
22  liboctinterp.12.dylib                        0x1042f40b4 octave_user_function::call(octave::tree_evaluator&, int, octave_value_list const&) + 164 (ov-usr-fcn.cc:562)
23  liboctinterp.12.dylib                        0x104425a64 octave::tree_index_expression::evaluate_n(octave::tree_evaluator&, int) + 1644 (pt-idx.cc:470)
24  liboctinterp.12.dylib                        0x104426e18 octave::tree_index_expression::evaluate(octave::tree_evaluator&, int) + 64 (pt-idx.h:105)
25  liboctinterp.12.dylib                        0x1043e4454 octave::tree_evaluator::visit_statement(octave::tree_statement&) + 552 (pt-eval.cc:4072)
26  liboctinterp.12.dylib                        0x104439710 octave::tree_statement::accept(octave::tree_walker&) + 40 (pt-stmt.h:125)
27  liboctinterp.12.dylib                        0x1043e4b98 octave::tree_evaluator::visit_statement_list(octave::tree_statement_list&) + 180 (pt-eval.cc:4157)
28  liboctinterp.12.dylib                        0x104128590 octave::tree_statement_list::accept(octave::tree_walker&) + 40 (pt-stmt.h:215)
29  liboctinterp.12.dylib                        0x1043e248c octave::tree_evaluator::execute_user_script(octave_user_script&, int, octave_value_list const&) + 532 (pt-eval.cc:3633)
30  liboctinterp.12.dylib                        0x1042f1e40 octave_user_script::execute(octave::tree_evaluator&, int, octave_value_list const&) + 56 (ov-usr-fcn.cc:210)
31  liboctinterp.12.dylib                        0x1042f1d64 octave_user_script::call(octave::tree_evaluator&, int, octave_value_list const&) + 128 (ov-usr-fcn.cc:203)
32  liboctinterp.12.dylib                        0x10442253c octave::tree_identifier::evaluate_n(octave::tree_evaluator&, int) + 696 (pt-id.cc:128)
33  liboctinterp.12.dylib                        0x104422acc octave::tree_identifier::evaluate(octave::tree_evaluator&, int) + 64 (pt-id.h:101)
34  liboctinterp.12.dylib                        0x1043e4454 octave::tree_evaluator::visit_statement(octave::tree_statement&) + 552 (pt-eval.cc:4072)
35  liboctinterp.12.dylib                        0x104439710 octave::tree_statement::accept(octave::tree_walker&) + 40 (pt-stmt.h:125)
36  liboctinterp.12.dylib                        0x1043e4b98 octave::tree_evaluator::visit_statement_list(octave::tree_statement_list&) + 180 (pt-eval.cc:4157)
37  liboctinterp.12.dylib                        0x104128590 octave::tree_statement_list::accept(octave::tree_walker&) + 40 (pt-stmt.h:215)
38  liboctinterp.12.dylib                        0x1043d4b84 octave::tree_evaluator::eval(std::__1::shared_ptr<octave::tree_statement_list>&, bool) + 52 (pt-eval.cc:1000)
39  liboctinterp.12.dylib                        0x1043d566c octave::tree_evaluator::repl() + 948 (pt-eval.cc:817)
40  liboctinterp.12.dylib                        0x1047d62f0 octave::interpreter::main_loop() + 48
41  liboctinterp.12.dylib                        0x1047d4f64 octave::interpreter::execute() + 752
42  liboctgui.11.dylib                           0x1014f9c7c octave::interpreter_qobject::execute() + 728 (interpreter-qobject.cc:88)
43  liboctgui.11.dylib                           0x1015d64a8 QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (octave::interpreter_qobject::*)()>::call(void (octave::interpreter_qobject::*)(), octave::interpreter_qobject*, void**) + 156 (qobjectdefs_impl.h:145)
44  liboctgui.11.dylib                           0x1015d63c0 void QtPrivate::FunctionPointer<void (octave::interpreter_qobject::*)()>::call<QtPrivate::List<>, void>(void (octave::interpreter_qobject::*)(), octave::interpreter_qobject*, void**) + 80 (qobjectdefs_impl.h:182)
45  liboctgui.11.dylib                           0x1015d62b0 QtPrivate::QCallableObject<void (octave::interpreter_qobject::*)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) + 192 (qobjectdefs_impl.h:553)
46  QtCore                                       0x102bc8624 QObject::event(QEvent*) + 300
47  QtWidgets                                    0x108713f28 QApplicationPrivate::notify_helper(QObject*, QEvent*) + 272
48  QtWidgets                                    0x108714e5c QApplication::notify(QObject*, QEvent*) + 516
49  liboctgui.11.dylib                           0x1015cb1b4 octave::octave_qapplication::notify(QObject*, QEvent*) + 64 (octave-qobject.cc:151)
50  QtCore                                       0x102b944ec QCoreApplication::notifyInternal2(QObject*, QEvent*) + 204
51  QtCore                                       0x102b95214 QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) + 520
52  QtCore                                       0x102cb4f5c QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 68
53  QtCore                                       0x102b9b0c8 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 448
54  QtCore                                       0x102c40c78 QThread::exec() + 156
55  QtCore                                       0x102cb37b8 QThreadPrivate::start(void*) + 336
56  libsystem_pthread.dylib                      0x19e6e82e4 _pthread_start + 136
57  libsystem_pthread.dylib                      0x19e6e30fc thread_start + 8

Thread 2:
0   libsystem_kernel.dylib                       0x19e6b2960 __sigwait + 8
1   libsystem_pthread.dylib                      0x19e6e8a9c sigwait + 40
2   liboctave.11.dylib                           0x10673726c signal_watcher(void*) + 48 (cxx-signal-helpers.cc:179)
3   libsystem_pthread.dylib                      0x19e6e82e4 _pthread_start + 136
4   libsystem_pthread.dylib                      0x19e6e30fc thread_start + 8

Thread 3:: com.apple.NSEventThread
0   libsystem_kernel.dylib                       0x19e6a6f54 mach_msg2_trap + 8
1   libsystem_kernel.dylib                       0x19e6b9604 mach_msg2_internal + 80
2   libsystem_kernel.dylib                       0x19e6afaf8 mach_msg_overwrite + 480
3   libsystem_kernel.dylib                       0x19e6a729c mach_msg + 24
4   CoreFoundation                               0x19e7d0a3c __CFRunLoopServiceMachPort + 160
5   CoreFoundation                               0x19e7cf29c __CFRunLoopRun + 1212
6   CoreFoundation                               0x19e7ce724 CFRunLoopRunSpecific + 588
7   AppKit                                       0x1a245da20 _NSEventThread + 148
8   libsystem_pthread.dylib                      0x19e6e82e4 _pthread_start + 136
9   libsystem_pthread.dylib                      0x19e6e30fc thread_start + 8

Thread 4:
0   libsystem_pthread.dylib                      0x19e6e30e8 start_wqthread + 0


Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Thu 16 Jan 2025 04:59:30 PM UTC, comment #3: 

I tried to reproduce the issue on Windows, it also crashes here. However, it seems to be crashing in a different way...
Top of the backtrace from that crash here:

Thread 4 "QThread" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 32936.0x7914]
0x0000023300000000 in ?? ()
(gdb) bt
#0  0x0000023300000000 in ?? ()
#1  0x00007fff5af585cb in octave_base_value::as_uint16 (this=0x5a891f8800) at ../libinterp/octave-value/ov-base.cc:204
#2  0x00007fff5b5a7f78 in octave::user_code_provider::user_code_provider (this=0x5a891f8990, who="get_breakpoint_list", fcn_ident="@my_class/is_zero", pfcn=0x233a68d08b0, silent=false)
    at ../libinterp/parse-tree/bp-table.cc:765
#3  0x00007fff5aff2449 in octave::bp_table::get_breakpoint_list[abi:cxx11](octave_value_list const&) (this=0x23386ccc878, fname_list=...) at ../libinterp/parse-tree/bp-table.cc:1249
#4  0x00007fff5b0fb15d in octave::Fdbstatus (interp=..., args=..., nargout=0) at ../libinterp/corefcn/debug.cc:425
#5  0x00007fff5b039268 in octave::tree_evaluator::execute_builtin_function (this=0x23386ccc818, builtin_function=..., nargout=0, args=...) at ../libinterp/parse-tree/pt-eval.cc:3554
#6  0x00007fff5af61f5b in octave_builtin::execute (this=0x23391dc33e0, tw=..., nargout=0, args=...) at ../libinterp/octave-value/ov-builtin.cc:49
#7  0x00007fff5af93530 in octave_function::call (this=0x23391dc33e0, tw=..., nargout=0, args=...) at ../libinterp/octave-value/ov-fcn.cc:74
#8  0x00007fff5b043bc0 in octave::tree_identifier::evaluate_n (this=0x233a6811730, tw=..., nargout=0) at ../libinterp/parse-tree/pt-id.cc:128


Fwiw, if Matlab detects that a user would like to save a file which is in the current dbstack, it asks whether the user would like to stop debugging or defer saving the file to later.
I don't know if Octave could do something similar...

Markus Mützel <mmuetzel>
Group administrator
Tue 14 Jan 2025 08:33:13 PM UTC, comment #2: 

m_fcn is a nullptr when the crash occurs. Here the backtrace back to "dbstatus":

0  0x00007f4d4885cdb6  octave::user_code_provider::user_code_provider
1  0x00007f4d48859b16  octave::bp_table::remove_all_breakpoints_from_function
2  0x00007f4d48a5162e  octave::out_of_date_check
3  0x00007f4d48a52842  octave::fcn_info::fcn_info_rep::find_method
4  0x00007f4d48e4a1e4  octave::fcn_info::find_method
5  0x00007f4d48e46b91  octave::symbol_table::find_method
6  0x00007f4d488d27de  octave::tree_evaluator::get_user_code
7  0x00007f4d4885a3aa  octave::bp_table::get_breakpoint_list[abi:cxx11](octave_value_list const&)
8  0x00007f4d48a1d16b  octave::Fdbstatus


Torsten Lilge <ttl>
Group Member
Tue 14 Jan 2025 07:46:44 AM UTC, comment #1: 

This might also be a regression from when (basic) support for setting breakpoints in classdef classes was added some time last year.

I'll try to look into it when I come around to it. But I don't know when that will be. So, I won't mind if anyone else would like to look into the issue first.
Is m_fcn a nullptr when that crash occurs? Or is it a "random" pointer?

Markus Mützel <mmuetzel>
Group administrator
Mon 13 Jan 2025 07:13:16 PM UTC, original submission:  

Steps to reprodcue:

  1. Consider as a minimal example the simple old style class "my_class" which is attached to this report together with a test script
  2. >> y = my_class (10)
  3. >> dbstop @my_class/is_zero 3
  4. >> is_zero (y)
  5. Modify and save @my_class/is_zero.m
  6. >> dbstatus
  7. Crash with SIGSEGV


The commands above are also included in 'dbg_my_class.m'

The crash occurs in bp-table.cc:765:

760  user_code_provider (const std::string& who, const std::string& fcn_ident,
761                        octave_user_code *pfcn, bool silent = false)
762      : m_fcn (nullptr), m_is_valid (false)
763    {
764      m_fcn = pfcn;
765      bool f1 = m_fcn->is_classdef_method ();
766      bool f2 = m_fcn->is_classdef_constructor ();

To my findings, fcn-info.cc:646 (in out_of_date_check) is also involved:

646 bptab.remove_all_breakpoints_from_function (canonical_nm,
647                                             true);

Here, canonical_nm does only contain "is_zero" instead of "@my_class/is_zero". Could this be the cause?

I was also thinking that this might be related to my changes in cset https://hg.savannah.gnu.org/hgweb/octave/rev/85ca9f4242c5 but the crash occurs in build without these changes as well.

Torsten Lilge <ttl>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #56771:  my_class.tar.xz added by ttl (492B - application/x-xz)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by dasergatskov (Posted a comment)
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by ttl (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.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-01-13 ttl Attached File- Added my_class.tar.xz, #56771

    Back to the top

    Powered by Savane 3.14-9aa3.
    Corresponding source code