bugGNU Octave - Bugs: bug #59938, Repeatable crash on pasting text...

 
 

bug #59938: Repeatable crash on pasting text with blank lines into Octave command prompt (CLI not GUI)

Submitter:  None
Submitted:  Mon 25 Jan 2021 12:34:40 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 6.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

Tue 26 Jan 2021 07:13:56 PM UTC, comment #12: 

Hmm, looking again, I think my comment #9 was wrong about what is happening, at least with the version of readline that I'm using (8.1).  It seems to handle bracketed paste mode correctly.  After pasting input at the prompt, readline waits for the user to press RET to enter the commands.  But Octave is not correctly handling input that includes embedded newline characters.  I'll take a look at that problem.

John W. Eaton <jwe>
Group administrator
Mon 25 Jan 2021 08:00:51 PM UTC, comment #11: 

Will do! Thank you for the fix!

Anonymous
Mon 25 Jan 2021 08:00:41 PM UTC, comment #10: 

The extended copy/paste (f = 6) works for me.  This is with "set enable-bracketd-paste on" (no workaround).

Rik <rik5>
Group administrator
Mon 25 Jan 2021 07:58:27 PM UTC, comment #9: 

Yes, because with bracketed paste mode on the shell is surrounding the pasted text with some markers that Octave currently doesn't handle.

John W. Eaton <jwe>
Group administrator
Mon 25 Jan 2021 07:52:55 PM UTC, comment #8: 

OP here. Am I still required to retain the .inputrc file with the "set enable-bracketed-paste off" workaround?

This is the input to copy-paste:

a = 1
b = 2
c = 3

d = 4
e = 5
f = 6


With the .inputrc workaround, the pasting works fine. Without it, I get a parse error, though not a crash:

$ octave -f -q
octave:1> a = 1
b = 2
c = 3

d = 4
e = 5
f = 6
error: parse error:

  syntax error

>>> a = 1
b = 2
c = 3

d = 4
e = 5
f = 6
    ^


Anonymous
Mon 25 Jan 2021 06:51:20 PM UTC, comment #7: 

The changeset works for me.  Marking as fixed and closing report.

Rik <rik5>
Group administrator
Mon 25 Jan 2021 06:31:26 PM UTC, comment #6: 

I pushed the following change on stable and merged with default:

http://hg.savannah.gnu.org/hgweb/octave/rev/6264fb660f72

John W. Eaton <jwe>
Group administrator
Mon 25 Jan 2021 03:49:45 AM UTC, comment #5: 

Rik, your workaround with " set enable-bracketed-paste off" works very well. Thank you for that.

It looks like the crash can be triggered by pasting three or more lines (= two line breaks), even if they don't have empty lines. Pasting two lines (= one line break) causes a parse error at the location of the line break.

Anonymous
Mon 25 Jan 2021 02:47:11 AM UTC, comment #4: 

Following the backtrace, things appear correct at #5, oct-pars.yy:4963.  At that point,


input="what\nwhos\n\nls"


which is what one would expect.

I think things might start to go sideways at #3, oct-parse.yy:398.  The code is


input           : simple_list '\n'
                  {
                    OCTAVE_YYUSE ($2);

                    $$ = nullptr;
                    std::shared_ptr<octave::tree_statement_list> tmp_lst ($1);
                    parser.statement_list (tmp_lst);
                    YYACCEPT;
                  }



Rik <rik5>
Group administrator
Mon 25 Jan 2021 02:18:44 AM UTC, comment #3: 

Here's a backtrace from the development branch (should be pretty much the same as stable).


#0  0x00007f02e79caa74 in std::__cxx11::list<octave::tree_statement*, std::allocator<octave::tree_statement*> >::empty (this=0x8)
    at /usr/include/c++/7/bits/stl_list.h:962
#1  0x00007f02e79c971a in octave::base_list<octave::tree_statement*>::empty (this=0x0) at ./liboctave/util/base-list.h:50
#2  0x00007f02e7a68509 in octave::base_parser::statement_list (this=0x7f02b01ee5e0,
    lst=std::shared_ptr<octave::tree_statement_list> (use count 1, weak count 0) = {...}) at libinterp/parse-tree/oct-parse.yy:2533
#3  0x00007f02e7a60920 in octave_push_parse (yyps=0x7f02b0450f80, yypushed_char=10, yypushed_val=0x7f02bdd40138, parser=...)
    at libinterp/parse-tree/oct-parse.yy:398
#4  0x00007f02e7a70e7e in octave::push_parser::run (this=0x7f02b01ee5e0, input="what\nwhos\n\nls", eof=false) at libinterp/parse-tree/oct-parse.yy:4895
#5  0x00007f02e7a711c8 in octave::push_parser::run (this=0x7f02b01ee5e0) at libinterp/parse-tree/oct-parse.yy:4963
#6  0x00007f02e7a9d2c0 in octave::tree_evaluator::repl (this=0x7f02b0005838) at libinterp/parse-tree/pt-eval.cc:692
#7  0x00007f02e7e83000 in octave::interpreter::main_loop (this=0x7f02b0004a60) at libinterp/corefcn/interpreter.cc:1220
#8  0x00007f02e7e7e082 in octave::interpreter::execute (this=0x7f02b0004a60) at libinterp/corefcn/interpreter.cc:814
#9  0x00007f02e8816aaf in octave::interpreter_qobject::execute (this=0x557cca27e0b0) at libgui/src/interpreter-qobject.cc:90
#10 0x00007f02e893c3b1 in octave::interpreter_qobject::qt_static_metacall (_o=0x557cca27e0b0, _c=QMetaObject::InvokeMetaMethod, _id=3,
    _a=0x557cca39d560) at libgui/src/moc-interpreter-qobject.cc:95
#11 0x00007f02e33060c2 in QObject::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#12 0x00007f02e405483c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#13 0x00007f02e405c104 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#14 0x00007f02e888bf04 in octave::octave_qapplication::notify (this=0x557cca1f6200, receiver=0x557cca27e0b0, ev=0x557cca2e8230)
    at libgui/src/octave-qobject.cc:132
#15 0x00007f02e32d68d8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#16 0x00007f02e32d904d in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#17 0x00007f02e3330263 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#18 0x00007f02db8f9417 in g_main_context_dispatch () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#19 0x00007f02db8f9650 in ?? () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#20 0x00007f02db8f96dc in g_main_context_iteration () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#21 0x00007f02e332f88f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#22 0x00007f02e32d490a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#23 0x00007f02e30f323a in QThread::exec() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#24 0x00007f02e30f817d in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#25 0x00007f02e28936db in start_thread (arg=0x7f02bdd48700) at pthread_create.c:463
#26 0x00007f02e578971f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95


Rik <rik5>
Group administrator
Mon 25 Jan 2021 02:13:04 AM UTC, comment #2: 

Confirmed.  This also occurs with the just-released Octave-6.1.0 and the current stable branch Octave-6.1.1.  As you say, this is a regression from version 5.2.0 where this worked.

I'm able to work around the issue by adding this line to my ~/.inputrc file.


set enable-bracketed-paste off


Does this work for you?

Rik <rik5>
Group administrator
Mon 25 Jan 2021 12:46:46 AM UTC, comment #1: 

More data if it helps you.

Input was this:

vec1 = find(mat1(:,cols(1)));
vec2 = find(mat1(:,cols(2)));
vec3 = find(mat1(:,cols(3)));
vec4 = find(mat1(:,cols(4)));


Test: Paste first one line into the Octave command prompt, then two lines, then three lines, etc.

Expected result: Some complaints about undefined variables cols or mat1.

Actual result for pasting one line: Expected result.

Actual result for pasting two lines: parse error / syntax error.

Actual result for pasting three lines: crash.


$ octave -f -q
octave:1> vec1 = find(mat1(:,cols(1)));
error: 'cols' undefined near line 1, column 1
octave:2> vec1 = find(mat1(:,cols(1)));
vec2 = find(mat1(:,cols(2)));
error: parse error:

  syntax error

>>> vec1 = find(mat1(:,cols(1)));
vec2 = find(mat1(:,cols(2)));
       ^
octave:2> vec1 = find(mat1(:,cols(1)));
vec2 = find(mat1(:,cols(2)));
vec3 = find(mat1(:,cols(3)));
fatal: caught signal Segmentation fault -- stopping myself...
Segmentation fault (core dumped)


Anonymous
Mon 25 Jan 2021 12:34:40 AM UTC, original submission:  

GNU Octave Version: 7.0.0 (hg id: 843b1f794544)
Xfce Terminal Emulator xfce4-terminal 0.8.10
GNU bash, version 5.1.0(1)-release (x86_64-pc-linux-gnu)

There is a repeatable crash on pasting a multi-line block of code with empty lines into the Octave command prompt. For other copy-paste input, there is a parse error even for legal input.

This happens only when starting Octave from the shell prompt (CLI mode), not when starting in the GUI mode.

This is recent behavior, so it's a regression.

Input (copy one or more lines and paste into the Octave command prompt):

what
whos

ls

(Note that there is a blank line between whos and ls.)

On copy-pasting the first two lines (what and whos separated by a newline):

$ octave -f -q
octave:1> what
whos
error: parse error:

  syntax error

>>> what
whos
       ^


On copy-pasting the first three lines, including the empty line:

$ octave -f -q
octave:1> what
whos

fatal: caught signal Segmentation fault -- stopping myself...
Segmentation fault (core dumped)


Crash happens on copying the second and third line too:

$ octave -f -q
octave:1>
octave:1> whos

fatal: caught signal Segmentation fault -- stopping myself...
Segmentation fault (core dumped)
$


On pasting the third and fourth lines (empty line and ls), there's a parse error.

$ octave -f -q
octave:1>
ls
error: parse error:

  syntax error

>>>
ls
     ^
octave:1>


For comparison, pasting shell commands separated by empty lines at the bash prompt does not cause problems. This indicates it is not a problem with the shell or with the terminal emulator, but likely the Octave interpreter running in CLI mode.

Anonymous

 

(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

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-01-26 mmuetzel Dependencies- bugs #59944 is dependent
    2021-01-25 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2021-01-25 jwe StatusConfirmed Ready For Test
    2021-01-25 rik5 StatusFixed Confirmed
    2021-01-25 rik5 StatusNone Fixed
        Releasedev 6.1.0

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code