bugGNU Octave - Bugs: bug #59237, Crash when pasting 64 commands

 
 

bug #59237: Crash when pasting 64 commands

Submitter:  T Knauss <tknauss>
Submitted:  Thu 08 Oct 2020 09:16:19 PM UTC
   
 
Category:  GUI Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * 5.2.0 Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 26 Oct 2020 07:46:57 PM UTC, comment #15: 

@Comment #14: This worked a little more predictably for me. Try appending "pause (0.25);" to the end of every statement that you're going to paste. The delay seems to prevent crashes or race conditions.

Anonymous
Sat 24 Oct 2020 01:13:06 PM UTC, comment #14: 

But it is not only a runtime topic. I can easily reproduce the segfault mentioned in the very first comment (by the OP) on hg id 9c3f4e9a0c83 on linux fedora with just a few commands. i tried the release candiate on win 7 and that looks more robust. different backtraces stop at different locations so it is weird. Over here until the following command pasting is fine, but then suddenly 'TS' appears to be undefined:

>> T_MORS=TS*TR*TO*TM
error: 'TS' undefined near line 1, column 1
>> T_MOS=TS*TO*TM
error: 'TS' undefined near line 1, column 1


But 'TS' exists in the workspace and can even be used if i execute following lines as a single command (=single line execution), right after the commands above:


>> TS
TS = (sym 3×3 matrix)

  ⎡sₓ   0   0⎤
  ⎢          ⎥
  ⎢0   s_y  0⎥
  ⎢          ⎥
  ⎣0    0   1⎦

>> T_MORS=TS*TR*TO*TM
T_MORS = (sym 3×3 matrix)

  ⎡-m_y⋅sₓ⋅sin(α) + sₓ⋅cos(α)    mₓ⋅sₓ⋅cos(α) - sₓ⋅sin(α)    sₓ⋅x⋅cos(α) - sₓ⋅y⋅sin(α) ⎤
  ⎢                                                                                    ⎥
  ⎢m_y⋅s_y⋅cos(α) + s_y⋅sin(α)  mₓ⋅s_y⋅sin(α) + s_y⋅cos(α)  s_y⋅x⋅sin(α) + s_y⋅y⋅cos(α)⎥
  ⎢                                                                                    ⎥
  ⎣             0                           0                            1             ⎦


So to speak: "What i paste is not what i get"

Hg200 <hg200>
Sat 24 Oct 2020 12:03:47 PM UTC, comment #13: 

The command window on Windows needs a general overhaul imho.
Another big issue is the missing/incomplete support of non-ASCII characters.
It'd probably be possible to improve both of these issues by using a different API to the Windows console.
I'm hesitant to dive deep into this, given the fact that there are plans to replace the current implementation by a cross-platform widget.
I'd say this bug adds another point to the list of issues that might raise the priority of that project.

Having written that: If someone would like to submit a patch that fixes this issue in the shorter run, I'd be happy to review.

Markus Mützel <mmuetzel>
Group administrator
Fri 23 Oct 2020 06:01:37 PM UTC, comment #12: 

I don't see an internal limit, but if I understand correctly, the code for handling pasting in Windows processes each character from the paste buffer as a separate keypress event.  As each keypress event likely triggers some series of Qt signal/slot connections it is not surprising that it is a slow process.  Here is the code for that operation:

http://hg.savannah.gnu.org/hgweb/octave/file/9c3f4e9a0c83/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp#l1362

For the Unix terminal widget, the operation is different and appears to write the entire buffer at once to the pty that the terminal widget uses for passing keyboard input to Octave:

http://hg.savannah.gnu.org/hgweb/octave/file/9c3f4e9a0c83/libgui/qterminal/libqterminal/unix/TerminalModel.cpp#l155

Even with the Unix terminal approach, the input is parsed and executed and generates events for adding the input to the GUI command history each time a line is processed, etc.

Is it reasonable to expect that text pasted into the terminal window should behave as if it were a series of keypress events or should it be handled differently?

John W. Eaton <jwe>
Group administrator
Sun 18 Oct 2020 08:08:10 PM UTC, comment #11: 

I can confirm the behavior on Linux. Changing the buffer size of the GUI terminal does not have significant influence.

I tend to chose the "Won't" fix option since the terminal of the GUI should be replaced by a platform independent solution on the long run

Torsten Lilge <ttl>
Group Member
Sat 17 Oct 2020 05:42:33 PM UTC, comment #10: 

All of this is a stress test on Octave 7.0.0 on Linux. It is not representative of a normal user's behavior.

How to do the test:
1. Save attached file folsd.m and open in a text editor.

2. Copy whatever number of lines you are comfortable with copying, and paste them at Octave's command prompt. For CLI invoked from the terminal, I tested Ctrl-Shift-V and also right-click + Paste. For the GUI I tested right-click + Paste.

3. Plot the vector "a", which will indicate time performance.

4. For calibration, also invoke the file folsd.m as a script from the Octave prompt to see how long it takes.

Results:

For the CLI, there is absolutely no problem pasting all 10000 lines. It takes less than a second to paste everything and the time behavior is very much linear.

For the GUI, I can paste up to approximately 511 to 530 lines. That takes about 3 seconds on my machine, and there are a couple of time skips as shown (Figure attached). This is repeatable behavior.

Pasting more than about 530 lines in the GUI simply doesn't work for me. It doesn't crash but it completely stops responding. The number of lines that can be pasted in the GUI is reduced by a lot if the lines are longer.

No doubt there is some internal limit to how much can be copy-pasted at the GUI prompt, and it is much lower and much slower than the CLI's limits. BUT this is easily worked around by saving everything as a script file and executing that. Even with the GUI that takes less than a second.

Close this bug as Won't Fix because of an easy workaround?


(file #50001,

Anonymous
Sat 10 Oct 2020 06:39:33 PM UTC, comment #9: 

The slow performance while pasting things into the GUI window is the core problem. It gets escalated to a crash when external packages like SymPy are also being called during that time. A 35-minute response time is as bad as it becoming frozen and unresponsive.

Attached two files safeToPaste.txt (16 lines of data) and unsafeToPaste.txt (17 lines). Pasting 16 lines of content or fewer in the GUI works without any surprises. Pasting more than 16 lines causes a freeze on Linux for version 7.0, and a long wait on Windows for version 5.2.

Workarounds to this problem: avoid pasting more than 16 lines into the GUI until the problem is resolved. Either save as a .m script and call that, or use the CLI to paste things.

(file #49960, file #49961)

Anonymous
Fri 09 Oct 2020 08:52:51 PM UTC, comment #8: 

The pasting in the CLI completed after about 35 minutes. Size of the array is 28x256.
It looks like the time for pasting a line is related to the number of lines left. This would explain why it continuously becomes faster. The last lines took approx 16, 10, 4 and 2 sec.

But as there is no permanent freezing and no crash, it's not related to my problem.

T Knauss <tknauss>
Fri 09 Oct 2020 08:28:51 PM UTC, comment #7: 

confirmation revoked!
It just seems to freeze. After about some minutes the first line appears in the command window (exact time unknown in GUI, no interest to repeat the test, 2.5 min in CLI). It's just really slow, but it finally works. And it definitely becomes continuously faster towards the end.
My CPU is Intel i7-8550U.

T Knauss <tknauss>
Fri 09 Oct 2020 08:11:30 PM UTC, comment #6: 

confirmed.
GUI freezed. CPU load 12.5% (=100% on one CPU core) @ conhost.exe (sub-process of octave-gui.exe).

But this seems to be a different problem though, it does not crash the GUI.

T Knauss <tknauss>
Fri 09 Oct 2020 07:35:33 PM UTC, comment #5: 

File didn't attach. Here it is. Trying again.

(file #49956)

Anonymous
Fri 09 Oct 2020 07:33:15 PM UTC, comment #4: 

1. Bug is specific to copy-pasting into GUI window, not on CLI and not when scripted.

2. Bug is seen by OP on Windows. Unable to see that specific bug in Linux.

3. Related pasting-related bug can be seen on GUI in Linux. Open the attached file (foo.txt) in a text editor and paste the contents in Octave GUI. It basically freezes with long lines. (Linux)

Anonymous
Fri 09 Oct 2020 02:11:40 PM UTC, comment #3: 

I just tried pasting into the CLI instead of the GUI, and I was NOT able to reproduce it there. Seems like this is indeed related to the GUI. Maybe a timing issue when invoking methods.

To answer your the questions:
1. No, it does not crash when invoked from a script.
2. I don't want to do experiments with my business computer. It works when I paste in blocks of 16, which is acceptable for me. Therefore I will not test with different versions of Python.

During further tests, I found more "bugs":
When pasting the 7 "preparation" lines multiple times, Octave at the 2nd pasting either
- works as expected without errors
- crashes without notice, no errors in diary
- shows error messages like: (empty lines removed by me)
(...)

>> syms alpha m_x m_y s_x s_y x y

error: if: undefined value used in conditional expression
(...)

>> TR = [[cos(alpha) -sin(alpha) 0]; [sin(alpha) cos(alpha) 0]; [0 0 1]]

TR = (sym 3x3 matrix)
  [cos(alpha)  -sin(alpha)  0]
  [                          ]
  [sin(alpha)  cos(alpha)   0]
  [                          ]
  [    0            0       1]

>> error: parse error

error: called from
    size at line 132 column 5
    ismember at line 125 column 5
    syms at line 102 column 5

>>


(...)

>> syms alpha m_x m_y s_x s_y x y

error: 'valid_sym_assumptions' undefined near line 82 column 9
error: called from
    size at line 84 column 3
    syms
(...)

>>


And I noticed that the calculation becomes really slow after many crashes. But no high CPU usage in Process Explorer.

T Knauss <tknauss>
Fri 09 Oct 2020 12:06:38 PM UTC, comment #2: 

Today I found that there is a command "diary on". I indeed actively searched for some logging functionality, because I noticed that there was an error message just before the Octave window disappeared.

Here's the relevant part of the log:

(... other output ...)

>> T_S=TS

T_S = (sym 3x3 matrix)

  [s_x   0   0]
  [           ]
  [ 0   s_y  0]
  [           ]
  [ 0    0   1]

>> T_SM=TM*TS

error: called from
    _makeinfo_ at line 141 column 22
    print_usage>get_usage_texinfo at line 131 column 20
    print_usage at line 61 column 30
    size at line 62 column 15
    compare_versions at line 137 column 25
    python_ipc_driver at line 36 column 5
    pycall_sympy__ at line 163 column 11
    mtimes at line 63 column 5
error: 'python_ipc_popen2' undefined near line 62 column 17

>> T_SMO=TO*TM*TS

error: called from
    print_usage at line 61 column 30
    size at line 62 column 15
    compare_versions at line 137 column 25
    python_ipc_driver at line 36 column 5
    pycall_sympy__ at line 163 column 11
    mtimes at line 63 column 5
error: 'TO' undefined near line 1 column 7

>> T_SMOR=TR*TO*TM*TS

error: called from
    print_usage at line 61 column 30
    size at line 62 column 15
    compare_versions at line 137 column 25
    python_ipc_driver at line 36 column 5
    pycall_sympy__ at line 163 column 11
    mtimes at line 63 column 5
error: 'TR' undefined near line 1 column 8

>> T_SMR=TR*TM*TS

error: called from
    print_usage at line 61 column 30
    size at line 62 column 15
    compare_versions at line 137 column 25
    python_ipc_driver at line 36 column 5
    pycall_sympy__ at line 163 column 11
    mtimes at line 63 column 5
error: 'TR' undefined near line 1 column 7

(... other output ...)

T Knauss <tknauss>
Fri 09 Oct 2020 01:57:11 AM UTC, comment #1: 

Two questions:

1. If all your commands are saved in a script and then invoked, does it still crash, or does it crash only when pasting?

2. Python 3.9.0 is extremely new. Does this crash happen with the more tested 3.8.xx?

Anonymous
Thu 08 Oct 2020 09:16:19 PM UTC, original submission:  

I am using "symbolic" package 2.9.0 and I have installed python 3.9 with sympy 1.5.1 (sympy 1.6.2 fails to work) on Win 10 Enterprise 1809 x64.

The commands to execute before pasting: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=TO*TS
T_SOM=TM*TO*TS
T_SOMR=TR*TM*TO*TS
T_SOR=TR*TO*TS
T_SORM=TM*TR*TO*TS
T_SR=TR*TS
T_SRM=TM*TR*TS
T_SRMO=TO*TM*TR*TS
T_SRO=TO*TR*TS
T_SROM=TM*TO*TR*TS

It crashes somewhere between T_RO and T_RS: Octave just quits without notice.

T Knauss <tknauss>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #50001:  folsd.m added by None (223KiB - text/x-objcsrc)
file #50002:  copy-paste-performance.png added by None (88KiB - image/png)
file #49960:  safeToPaste.txt added by None (23KiB - text/plain)
file #49961:  unsafeToPaste.txt added by None (25KiB - text/plain)
file #49956:  foo.txt added by None (41KiB - 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 hg200 (Posted a comment)
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by ttl (Posted a comment)
  • -email is unavailable- added by tknauss (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-10-17 None Attached File- Added folsd.m, #50001
        Attached File- Added copy-paste-performance.png, #50002
    2020-10-10 None Attached File- Added safeToPaste.txt, #49960
        Attached File- Added unsafeToPaste.txt, #49961
    2020-10-09 None Attached File- Added foo.txt, #49956

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code