bugGNU Octave - Bugs: bug #56435, Octave crashd while running unit...

 
 

bug #56435: Octave crashd while running unit test of an oct-file which uses pthreads

Submitter:  None
Submitted:  Tue 04 Jun 2019 09:04:05 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 5.1.0
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 06 Jun 2019 07:59:46 AM UTC, comment #7: 

I suppose i should run several instances of octave, each in a terminal, and make each instance run my main script with a different set of arguments, as a workaround.

Babak Razmjoo <babakrz63ai>
Thu 06 Jun 2019 07:54:08 AM UTC, comment #6: 

It is exactly what i'm trying to do. Thanks for answering

Babak Razmjoo <babakrz63ai>
Wed 05 Jun 2019 05:38:16 PM UTC, comment #5: 

I'm only guessing, but since you mentioned pthreads and the function is called pararrayfun, is it possible you are trying to evaluate Octave values or expressions in multiple threads simultaneously?

If that's the case, then this crash is definitely expected. The Octave interpreter is not safe to call from multiple threads, nor does Octave yet fully support creating multiple instances of the interpreter, for example one per thread. So I suspect you are trying to do something that Octave does not yet support, and that's not really a bug at this point.

If you modify your code so that you do not make Octave API calls in the pthread function, does that resolve the crash for you? In other words, only the main thread of your oct file can handle arguments and call Octave functions, and the pthread worker threads can do computations, but not any that depend on Octave.

Mike Miller <mtmiller>
Group Member
Wed 05 Jun 2019 09:21:17 AM UTC, comment #4: 

It is a better reproduction recipe. In octave run:

> for t=1:1000
> pararrayfun(2, @(x) 2*x, 1:8)'
> end


(file #47036)

Babak Razmjoo <babakrz63ai>
Wed 05 Jun 2019 07:31:30 AM UTC, comment #3: 

OK, the bug is more likely in my native code which uses pointers in the old C manner. It might be a missing feature that octave should support parallel computing itself, and should be more robust against bugs in user's native code.

To reproduce this crash you should:
1.Compile pararrayfun.cc which is attached to this report with mkoctfile
2. in octave prompt run :

> pararrayfun(2, @(x), 1:1000);


This can run several times without any problem, but at last the octave will get an ABORT or SIGSEGV signal and crashes.

Babak Razmjoo <babakrz63ai>
Tue 04 Jun 2019 08:54:31 PM UTC, comment #2: 

Thank you for taking the time to file a bug report. However, it looks like you are reporting a bug for code that you have written yourself using Octave. Can you be more specific what you believe the bug is here? Can you give a smaller reproducible example that shows that there is a bug in Octave?

Mike Miller <mtmiller>
Group Member
Tue 04 Jun 2019 09:16:56 AM UTC, comment #1: 

Note : You must run the unit tests several times before it crashes.

Babak Razmjoo <babakrz63ai>
Tue 04 Jun 2019 09:04:05 AM UTC, original submission:  

I have written a piece of native code to implement an alternative to 'pararrayfun' from parallel package. I need this alternative because from octave 4.4.1, parallel package doesn't work.

I have added some unit test for my pararrayfun implementation, and was testing it when octave crashed (terminated with signal SIGABRT).

How to build the oct-file:
$ export CXXFLAGS="-ggdb -Wall -O0"
$ mkoctfile -g -DDEBUG -o pararrayfun.oct pararrayfun.cc

This is the stack trace I get from the corresponding core dump using gdb:

#0  0x00007fb83d8e8eb5 in raise () from /lib64/libc.so.6
#1  0x00007fb83d8d3895 in abort () from /lib64/libc.so.6
#2  0x00007fb83d92bee7 in __libc_message () from /lib64/libc.so.6
#3  0x00007fb83d9327bc in malloc_printerr () from /lib64/libc.so.6
#4  0x00007fb83d93567c in _int_malloc () from /lib64/libc.so.6
#5  0x00007fb83d936d3f in malloc () from /lib64/libc.so.6
#6  0x00007fb83f8aa892 in octave_pstate_new ()
    at libinterp/parse-tree/oct-parse.cc:3012
#7  0x00007fb83f8af15e in octave::base_parser::base_parser (
    this=0x7fb81dbf7dc0, lxr=...) at /usr/include/c++/9/bits/stl_list.h:153
#8  0x00007fb83f8dd4b5 in octave::parser::parser (interp=..., eval_string="",
    this=0x7fb81dbf7dc0) at libinterp/parse-tree/lex.h:770
#9  octave::tree_evaluator::eval_string (this=0x7fb80c003a28, eval_str="",
    silent=false, parse_status=@0x7fb81dbf8014: 0, nargout=0)
    at libinterp/parse-tree/pt-eval.cc:203
#10 0x00007fb83f8dd96c in octave::tree_evaluator::eval_string (
    this=this@entry=0x7fb80c003a28, arg=..., silent=silent@entry=false,
    parse_status=@0x7fb81dbf8014: 0, nargout=nargout@entry=0)
    at libinterp/parse-tree/pt-eval.cc:287
#11 0x00007fb83fc6379c in octave::interpreter::eval_string (
    this=this@entry=0x7fb80c002de0, arg=..., silent=silent@entry=false,
    parse_status=@0x7fb81dbf8014: 0, nargout=nargout@entry=0)
    at libinterp/corefcn/interpreter.cc:1150
#12 0x00007fb83f8b52a1 in Feval (interp=..., args=..., nargout=0)
    at ./liboctave/array/Array.h:529
#13 0x00007fb83f6f19ab in octave_builtin::call (this=0x7fb80c032780, tw=...,
    nargout=0, args=...) at libinterp/octave-value/ov-builtin.cc:71
#14 0x00007fb83f8e53e1 in octave::tree_evaluator::visit_index_expression (
    this=0x7fb80c003a28, idx_expr=...) at libinterp/parse-tree/pt-eval.cc:2008
#15 0x00007fb83f7437f3 in octave::tree_evaluator::evaluate (
    this=0x7fb80c003a28, expr=0x7fb80cd0d480, nargout=<optimized out>)
    at libinterp/parse-tree/pt-eval.h:312
#16 0x00007fb83f8e261d in octave::tree_evaluator::visit_statement (
    this=0x7fb80c003a28, stmt=...) at libinterp/parse-tree/pt-eval.cc:2776
#17 0x00007fb83f8d6878 in octave::tree_statement::accept (tw=...,
    this=0x7fb80cd0d660) at libinterp/parse-tree/pt-stmt.h:119
#18 octave::tree_evaluator::visit_statement_list (this=0x7fb80c003a28, lst=...)
    at libinterp/parse-tree/pt-eval.cc:2845
#19 0x00007fb83f8e062c in octave::tree_statement_list::accept (tw=...,
    this=0x7fb80cc46580) at libinterp/parse-tree/pt-stmt.h:194
#20 octave::tree_evaluator::execute_user_function (this=0x7fb80c003a28,
    user_function=..., nargout=0, xargs=...)
    at libinterp/parse-tree/pt-eval.cc:1695
#21 0x00007fb83f808b8b in octave_user_function::call (this=<optimized out>,
    tw=..., nargout=<optimized out>, args=...)
    at libinterp/octave-value/ov-usr-fcn.cc:455
#22 0x00007fb83f8e53e1 in octave::tree_evaluator::visit_index_expression (this=0x7fb80c003a28, idx_expr=...) at libinterp/parse-tree/pt-eval.cc:2008
#23 0x00007fb83f7437f3 in octave::tree_evaluator::evaluate (this=0x7fb80c003a28, expr=0x7fb80d00bad0, nargout=<optimized out>) at libinterp/parse-tree/pt-eval.h:312
#24 0x00007fb83f8e261d in octave::tree_evaluator::visit_statement (this=0x7fb80c003a28, stmt=...) at libinterp/parse-tree/pt-eval.cc:2776
#25 0x00007fb83f8d6878 in octave::tree_statement::accept (tw=..., this=0x7fb80c43fbb0) at libinterp/parse-tree/pt-stmt.h:119
#26 octave::tree_evaluator::visit_statement_list (this=0x7fb80c003a28, lst=...) at libinterp/parse-tree/pt-eval.cc:2845
#27 0x00007fb83f8d8acb in octave::tree_statement_list::accept (tw=..., this=<optimized out>) at libinterp/parse-tree/pt-stmt.h:194
#28 octave::tree_evaluator::repl (this=0x7fb80c003a28, interactive=true) at libinterp/parse-tree/pt-eval.cc:106
#29 0x00007fb83fc6ab05 in octave::interpreter::execute (this=this@entry=0x7fb80c002de0) at libinterp/corefcn/interpreter.cc:694
#30 0x00007fb84031c680 in octave::octave_interpreter::execute (this=0x55a16e2e0010) at libgui/src/main-window.cc:146
#31 0x00007fb83c71042a in QObject::event(QEvent*) () from /lib64/libQt5Core.so.5
#32 0x00007fb83d0d1ad6 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /lib64/libQt5Widgets.so.5
#33 0x00007fb83d0daf50 in QApplication::notify(QObject*, QEvent*) () from /lib64/libQt5Widgets.so.5
#34 0x00007fb84031eb40 in octave::octave_qapplication::notify (this=<optimized out>, receiver=<optimized out>, ev=<optimized out>) at libgui/src/main-window.cc:2795
#35 0x00007fb83c6e52e8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /lib64/libQt5Core.so.5
#36 0x00007fb83c6e8253 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /lib64/libQt5Core.so.5
#37 0x00007fb83c73a667 in ?? () from /lib64/libQt5Core.so.5
#38 0x00007fb837a6efd0 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
#39 0x00007fb837a6f368 in ?? () from /lib64/libglib-2.0.so.0
#40 0x00007fb837a6f413 in g_main_context_iteration () from /lib64/libglib-2.0.so.0
#41 0x00007fb83c73a3f5 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQt5Core.so.5
#42 0x00007fb83c6e42bb in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQt5Core.so.5
#43 0x00007fb83c53d675 in QThread::exec() () from /lib64/libQt5Core.so.5
#44 0x00007fb83c53e7c6 in ?? () from /lib64/libQt5Core.so.5
#45 0x00007fb83beec5a2 in start_thread () from /lib64/libpthread.so.0
#46 0x00007fb83d9ac163 in clone () from /lib64/libc.so.6

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #47036:  pararrayfun.cc added by babakrz63ai (10KiB - text/x-c++src - A more improved version of my native code using vectors instead of pointers)
file #47025:  pararrayfun.cc added by None (9KiB - text/x-c++src)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by babakrz63ai (Posted a comment)
  •  

    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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-06-06 mtmiller StatusNeed Info Invalid / Not an Octave Bug
        Open/ClosedOpen Closed
    2019-06-05 babakrz63ai Attached File- Added pararrayfun.cc, #47036
    2019-06-04 mtmiller StatusNone Need Info
    2019-06-04 None Attached File- Added pararrayfun.cc, #47025

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code