bugGNU Octave - Bugs: bug #54187, fail to close a busy figure and...

 
 

bug #54187: fail to close a busy figure and crash octave

Submitted by:  None
Submitted on:  Tue 26 Jun 2018 03:19:43 AM UTC  
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Fixed Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  Closed Release:  4.4.0
Operating System:  GNU/Linux

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

( Jump to the original submission)

Sun 13 Jan 2019 04:37:03 PM UTC, comment #16: 

I have retested with the latest patch (from comment #15) included, the testing was done as in comment #13. As result: It all behaves nicely. Thanks for the patch, Pantxo!

Hartmut <hardy>
Fri 11 Jan 2019 05:22:42 PM UTC, comment #15: 
Pantxo Diribarne <pantxo>
Project Member
Thu 10 Jan 2019 10:01:39 PM UTC, comment #14: 

Sorry, but the "mcode" approach doesn't work with non integer figure handles, and "close (gcbf ())" won't work either due to bug #55428 ... so I'll rework the patch before pushing.

Pantxo Diribarne <pantxo>
Project Member
Thu 10 Jan 2019 07:58:04 PM UTC, comment #13: 

I have tested Pantxo's second patch (from comment #10), used on top of a recent stable octave (hg-id 2538ed43aa25):

  • I canNOT provoce any crash by the steps mentioned in comment #4.
  • Also NO CRASH with the steps from comment #0.
  • NO CRASH with the steps from comment #6.

So to me this second patch seems as good as Pantxo's first step (from the result perspective). I would say this issue is now FIXED (once we push this patch...)

Hartmut <hardy>
Thu 10 Jan 2019 04:46:05 PM UTC, comment #12: 

I marked the bug as fixed at https://wiki.octave.org/Bug_Fix_List_-_5.0_Release#Bugs_marked_as_Crash.

There are some other crashes that are probably fixed by this such as

bug #49758: octave-cli crashes when closing fullscreen plot

Rik <rik5>
Project Administrator
Thu 10 Jan 2019 04:42:37 PM UTC, comment #11: 

I tested with the code from the duplicate bug #55431 and it is all fixed.  I'd go ahead and push it and clos this report.

Rik <rik5>
Project Administrator
Thu 10 Jan 2019 09:16:18 AM UTC, comment #10: 

I attached an updated patch that fixes the issue for me (and correctly goes through gh_manager::execute_callback). If someone can confirm that it works, I'll push it on stable soon.

(file #45926)

Pantxo Diribarne <pantxo>
Project Member
Mon 07 Jan 2019 08:28:55 PM UTC, comment #9: 

@Harmut: Thanks for testing. The principle is there but I am not so happy with those new mcode_event objects. I'll rework the patch and make sure "close" is properly interpreted in gh_manager::do_execute_callback (where gcbo is setup among others).

Pantxo Diribarne <pantxo>
Project Member
Mon 07 Jan 2019 01:04:30 PM UTC, comment #8: 

I have compiled and tested a current dev Octave (hg-id bf835b1d04b1) without any additional patches:

  • I can reproduce the CRASH from comment #4
  • I can reproduce the CRASH from comment #0
  • (I have not tested the other ways of crashing)

When I then add Pantxo's patch from comment #7 and recompile:

  • I canNOT provoce any crash when trying the steps from comment #4. I can click as often as I want on the x in the plot windows. Using Ctrl-C afterwards in the Octave console will properly stop the while look and Octave is still alive.
  • I also canNOT provoce any crash with the steps in comment #0. The figure window just nicly closes, when clicking the x in the window.
  • Also the figure windows from comment #2 just neatly closes, when clicking the x in the figure window. NO CRASH.
  • I don't know if I did those steps all right (because I haven't tested this with unpatched Octave). But I was not able to provoce ANY CRASH with the steps mentioned in comment #6 either. Clicking on x closes the figure window fine. But to get my Octave console back, I still also have to Ctrl-C. But this seems fine to me (the code is an endless loop nevertheless.)

So this patch is definitly an improvement. Can anyone else confirm, that Pantxo's patch fully FIXES this issue?

Hartmut <hardy>
Mon 07 Jan 2019 10:25:07 AM UTC, comment #7: 

I attached a patch that fixes the issue for me.

(file #45887)

Pantxo Diribarne <pantxo>
Project Member
Wed 11 Jul 2018 01:58:03 AM UTC, comment #6: 

It seems that in Octave 4.4.0 graphics_toolkit qt, there might be something wrong with the menu "File > Close Figure  Ctrl+W" (or the window "x" button).

If I run

figure();
while 1
  drawnow(); pause(0.1);
end

in Octave 4.2.x, everything works well; all the menus can response in time.

But in Octave 4.4.0, everything works well (e.g. "File > Save", "Help > About Octave", as well as user-defined menus)
except for the "File > Close Figure" —— not only it cannot close the figure in time, but also it may crash Octave with Segfault later.

A workaround in 4.4.0 is to add a user-defined menu, such as

h = uimenu('label', 'My File' );
uimenu(h, 'label', 'My Close', 'callback', 'close');

while 1
  drawnow(); pause(0.1);
end

The additional menu "My File > My Close" works well; it can close the figure in time.
But, again, we must NOT click the original menu "File > Close Figure" which doesn't work and may crash Octave.

Anonymous
Sat 07 Jul 2018 02:09:12 AM UTC, comment #5: 

In summary, I find that in Octave 4.4.0 with graphics_toolkit qt
clicking on a figure "x" button more than once before Octave returns to the command interpreter prompt
will make Octave exit with signal 11 (Segfault).

Anonymous
Fri 06 Jul 2018 09:08:54 PM UTC, comment #4: 

I can't reproduce your suggestion with Octave from development branch. But i can crash it if i run

figure();
while 1
end

Then click on the figure "x" button. Then go to the command window and press Ctrl-C. Then octave exits with signal 11.

Hg200 <hg200>
Mon 02 Jul 2018 12:29:45 AM UTC, comment #3: 

Only octave 4.4.0 with graphics_toolkit qt has this bug.

octave 4.4.0 with graphics_toolkit fltk does not have this bug.

octave 4.2.x with any graphics_toolkit does not have this bug.

Anonymous
Tue 26 Jun 2018 07:50:14 AM UTC, comment #2: 

I tried another simpler example:
1) edit a function file tmp2.m (see below);
2) if run "tmp2", and press Ctrl+C, then nothing abnormal;
3) if run "tmp2", use mouse to close the figure ONCE (but the figure is not closed immediately in octave 4.4.0), and press Ctrl+C (until now the figure is closed in octave 4.4.0);
4) if run "tmp2", use mouse to close the figure TWICE, and press Ctrl+C, then the function "close" will report an error.
5) if run "tmp2", use mouse to close the figure THREE TIMES OR MORE, and press Ctrl+C, then the function "close" will report an error, and octave will crash with segfault.

user@debian:~$  cat tmp2.m
function tmp2
  a = imread('octave-sombrero.png');
  h = imshow(a);
  while (ishandle(h))
    a = shift(a,1);
    set(h,'cdata',a);
    drawnow;
    pause(0.01);
  end
end

user@debian:~$  octave -q
octave:1> tmp2 # do not click "X"
^C
octave:1> tmp2 # and click "X" once
^C
octave:1> tmp2 # and click "X" twice
^C
octave:1> error: close: first argument must be "all", a figure handle, or a figure name
error: parse error
error: called from
    close at line 81 column 7
octave:1> tmp2 # and click "X" three times or more
^C
octave:1> error: close: first argument must be "all", a figure handle, or a figure name
error: parse error
error: called from
    close at line 81 column 7
octave:1> fatal: caught signal Segmentation fault -- stopping myself...
Segmentation fault

user@debian:~$

Anonymous
Tue 26 Jun 2018 06:52:38 AM UTC, comment #1: 

I find one difference between octave 4.2.x and 4.4.0 :

in octave 4.2.x, using mouse or shortcut key to close the figure does NOT call the function "close" (it only calls "closereq" and then "delete")

but in octave 4.4.0, this action will call the function "close" first (and then calls "closereq" and "delete").

Anonymous
Tue 26 Jun 2018 03:19:43 AM UTC, original submission:  

When a figure is busy, closing it (e.g. click the "X" button, press Alt+F4, or Ctrl+W, etc.) does not work.
What's more, in this case, if some code tries to close it, then octave would crash with segfault.

This happens in octave 4.4.0; octave 4.2.x does not have this problem.  Is this a regression ?

My environment is Debian GNU/Linux with LXDE desktop.

Here is an example how to reproduce this bug:
1) edit a function file tmp.m (see below);
2) start "octave" or "octave --gui";
3) run "tmp" at the octave prompt and we would see an image moving in a figure;
4) NOW use mouse or shortcut key to close this figure (but this would FAIL);
5) THEN press Ctrl+C at the octave prompt to interrupt "tmp", this would run the onCleanup code which tries to close the figure (but this would CRASH octave with segfault)

user@debian:~$  cat tmp.m
function tmp
  a = imread('octave-sombrero.png');
  h = imshow(a);
  f = gcf();
  o = onCleanup(@() isfigure(f) && close(f));
  while (isfigure(f))
    a = shift(a,1);
    set(h,'cdata',a);
    drawnow;
    pause(0.01);
  end
end

user@debian:~$  octave
GNU Octave, version 4.4.0
Copyright (C) 2018 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type 'warranty'.

Octave was configured for "x86_64-pc-linux-gnu".

Additional information about Octave is available at https://www.octave.org.

Please contribute if you find this software useful.
For more information, visit https://www.octave.org/get-involved.html

Read https://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.

octave:1> tmp
^C
octave:1> fatal: caught signal Segmentation fault -- stopping myself...
Segmentation fault

user@debian:~$  octave --gui
octave exited with signal 11

user@debian:~$

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #45926:  safeclose2.patch added by pantxo (6KiB - text/x-patch)
file #45887:  safeclose.patch added by pantxo (5KiB - text/x-patch)

 

Depends on the following items: None found

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by hardy (Posted a comment)
  • -email is unavailable- added by pantxo (Updated the item)
  • -email is unavailable- added by hg200 (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-01-11 rik5 StatusReady For Test => Fixed
        Open/ClosedOpen => Closed
    2019-01-11 pantxo StatusPatch Reviewed => Ready For Test
    2019-01-10 rik5 StatusPatch Submitted => Patch Reviewed
    2019-01-10 pantxo Dependencies- => bugs #55431 is dependent
    2019-01-10 pantxo Attached File- => Added safeclose2.patch, #45926
    2019-01-07 pantxo Attached File- => Added safeclose.patch, #45887
        StatusNone => Patch Submitted

    Back to the top


    Powered by Savane 3.5