bugGNU Octave - Bugs: bug #46501, Crash running uimenu code under Qt

 
 

bug #46501: Crash running uimenu code under Qt

Submitted by:  Rik <rik5>
Submitted on:  Mon 23 Nov 2015 05:39:14 AM UTC
 
Category:  Plotting with OpenGL Severity:  4 - Important
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Fixed Assigned to:  jwe
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

( Jump to the original submission )

Fri 05 Aug 2016 02:28:45 PM UTC, comment #14: 

Can this bug report be closed?

John W. Eaton <jwe>
Project Administrator
Thu 28 Jul 2016 08:48:31 PM UTC, comment #13: 

I tested you fix and it seems to work!

I ran my old test file that crashed, and now it does not crash for me.

Doug Stewart <dastew>
Thu 28 Jul 2016 08:20:13 PM UTC, comment #12: 

I checked in the following changeset:

  http://hg.savannah.gnu.org/hgweb/octave/rev/e68128601f5e

This seems to fix the problem for me.  Maybe it will fix other crashes with QtHandles code.  I didn't do an extensive check, so there may be other places where attempts are made to use invalid graphics objects that also need to be fixed similarly.  If so, then maybe we need a cleaner way to do this other than cluttering up the code with repeated checks for valid objects.

John W. Eaton <jwe>
Project Administrator
Fri 15 Jul 2016 11:42:56 AM UTC, comment #11: 

Here is a freshened patch, reflecting the change from variable name "application" to "qt_app".

(file #37886)

Lachlan Andrew <lachlan>
Sat 02 Jul 2016 11:42:50 AM UTC, comment #10: 

Thanks for testing the patch, Doug.

You're right that the error occurred earlier and just couldn't be seen due to the crash.  Rik reported it in the original bug report -- it can be seen by running with --no-gui.

There is a race condition that needs to be fixed, but I don't see that as a blocker for 4.2.0, whereas the crash is.  Others can certainly overrule that opinion.

Lachlan Andrew <lachlan>
Sat 02 Jul 2016 11:26:53 AM UTC, comment #9: 

I tried your patch and it does stop the crashing, but now I see this error message:

error: base_graphics_object::get_properties: invalid graphics object

This message was not seen before, probably because the crash was fast, and the window was gone before we could see this error message.

When I single stepped through the prog. I did not get the error message.

I added a delay like:
H = findall(allchild(F),'flat');
pause(.5);
delete(H);

and this reduced the probability of the error happening.

Doug Stewart <dastew>
Wed 29 Jun 2016 01:11:33 PM UTC, comment #8: 

There are two components to this bug:
1. Why is an error being thrown?
2. Why is it not being caught?

I think that the answer to the second question is that the error is being thrown from the Qt thread, which doesn't have a try/catch around the code being executed.  I propose that we put try/catch around any callbacks executed by that thread, as per the attached patch.

This doesn't solve the fundamental problem, but it stops it from crashing.

I also got a stack trace from before the throw.  The main thing of interest is that it goes through

stack trace:
1: /home/lachlan/src/octave/.build/libinterp/.libs/liboctinterp.so.3 : ()+0x85c12f
2: /home/lachlan/src/octave/.build/libinterp/.libs/liboctinterp.so.3 : ()+0x85c2b6
3: /home/lachlan/src/octave/.build/libinterp/.libs/liboctinterp.so.3 : ()+0x85c317
4: /home/lachlan/src/octave/.build/libinterp/.libs/liboctinterp.so.3 : ()+0x85c3ac
5: /home/lachlan/src/octave/.build/libinterp/.libs/liboctinterp.so.3 : base_graphics_object::get_properties()+0x2c
6: /home/lachlan/src/octave/.build/libgui/.libs/liboctgui.so.1 : QtHandles::Panel::eventFilter(QObject*, QEvent*)+0xb7
7: /usr/lib/x86_64-linux-gnu/libQtCore.so.4 : QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*)+0x86
8: /usr/lib/x86_64-linux-gnu/libQtGui.so.4 : QApplicationPrivate::notify_helper(QObject*, QEvent*)+0x6c
9: /usr/lib/x86_64-linux-gnu/libQtGui.so.4 : QApplication::notify(QObject*, QEvent*)+0x270
10: /usr/lib/x86_64-linux-gnu/libQtCore.so.4 : QCoreApplication::notifyInternal(QObject*, QEvent*)+0x6d
11: /usr/lib/x86_64-linux-gnu/libQtGui.so.4 : QWidgetPrivate::sendPendingMoveAndResizeEvents(bool, bool)+0x1a1
12: /usr/lib/x86_64-linux-gnu/libQtGui.so.4 : QWidgetPrivate::show_helper()+0x23
13: /usr/lib/x86_64-linux-gnu/libQtGui.so.4 : QWidget::setVisible(bool)+0x194
14: /usr/lib/x86_64-linux-gnu/libQtGui.so.4 : QWidgetPrivate::showChildren(bool)+0x12e
15: /usr/lib/x86_64-linux-gnu/libQtGui.so.4 : QWidgetPrivate::show_helper()+0x3f
16: /usr/lib/x86_64-linux-gnu/libQtGui.so.4 : QWidget::setVisible(bool)+0x194
17: /usr/lib/x86_64-linux-gnu/libQtCore.so.4 : QObject::event(QEvent*)+0x24e
18: /usr/lib/x86_64-linux-gnu/libQtGui.so.4 : QWidget::event(QEvent*)+0xb1b
19: /usr/lib/x86_64-linux-gnu/libQtGui.so.4 : QFrame::event(QEvent*)+0x1e
20: /usr/lib/x86_64-linux-gnu/libQtGui.so.4 : QApplicationPrivate::notify_helper(QObject*, QEvent*)+0x8c
21: /usr/lib/x86_64-linux-gnu/libQtGui.so.4 : QApplication::notify(QObject*, QEvent*)+0x270
22: /usr/lib/x86_64-linux-gnu/libQtCore.so.4 : QCoreApplication::notifyInternal(QObject*, QEvent*)+0x6d
23: /usr/lib/x86_64-linux-gnu/libQtCore.so.4 : QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*)+0x1ef
24: /usr/lib/x86_64-linux-gnu/libQtCore.so.4 : ()+0x1aabf3
25: /lib/x86_64-linux-gnu/libglib-2.0.so.0 : g_main_context_dispatch()+0x146
26: /lib/x86_64-linux-gnu/libglib-2.0.so.0 : ()+0x481f8
27: /lib/x86_64-linux-gnu/libglib-2.0.so.0 : g_main_context_iteration()+0x2c
28: /usr/lib/x86_64-linux-gnu/libQtCore.so.4 : QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)+0x65
29: /usr/lib/x86_64-linux-gnu/libQtGui.so.4 : ()+0x266896
30: /usr/lib/x86_64-linux-gnu/libQtCore.so.4 : QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)+0x2f
terminate called after throwing an instance of 'octave_execution_exception'
panic: Aborted -- stopping myself...
attempting to save variables to 'octave-workspace'...
save to 'octave-workspace' complete
Aborted

(file #37622)

Lachlan Andrew <lachlan>
Wed 29 Jun 2016 12:27:27 PM UTC, comment #7: 

Ah yes.  I can see it now. I'll look into it.

Lachlan Andrew <lachlan>
Wed 29 Jun 2016 10:14:30 AM UTC, comment #6: 

I made a script that has
bad_plot
bad_plot
bad_plot
bad_plot

and this works  but if I add one more call to bad_plot then it does a hard crash right out of octave.

hg id  9e992b9ffc5f
Ubuntu 16.04

Doug Stewart <dastew>
Wed 29 Jun 2016 07:48:40 AM UTC, comment #5: 

This works for me with the current head (albeit with a few unrelated patches).

Can someone (Avinoam?) confirm that the issue no longer occurs?

Lachlan Andrew <lachlan>
Tue 24 Nov 2015 12:37:53 AM UTC, comment #4: 

Found another bug report, #44339, which looks to be the same behavior with uipanel and delete.

Rik <rik5>
Project Administrator
Tue 24 Nov 2015 12:23:31 AM UTC, comment #3: 

Doubtless this is a race condition.  I experimented with different sleep delays of 10ms, 100ms, 200ms.  The smallest delay exhibits a failure after ~8 iterations.  The 100ms delay exhibits a failure after ~85 iterations.  The 200ms delay passed all 100 iterations.

I don't know where to begin fixing this since it probably will involve threading (Qt) as well as semaphores in gl-render.cc.

Rik <rik5>
Project Administrator
Mon 23 Nov 2015 11:55:39 AM UTC, comment #2: 

If I add "sleep (1)" before the delete (H) it does not crash Octave (checked with dev branch version on Win 7)

Avinoam Kalma <avinoam>
Project Member
Mon 23 Nov 2015 05:41:00 AM UTC, comment #1: 

This is related to bug #44875.  In that bug, the warning is issued but it doesn't appear to crash Octave.

Rik <rik5>
Project Administrator
Mon 23 Nov 2015 05:39:14 AM UTC, original submission:  

The attached file bad_plot.m, when run with the qt toolkit, causes Octave to crash.  The file needs to be run twice for me to see the issue.

bad_plot
bad_plot

The backtrace under gdb isn't very informative, but here it is:

>> error: base_graphics_object::get_properties: invalid graphics object
terminate called after throwing an instance of 'octave_execution_exception'

Program received signal SIGABRT, Aborted.
0x00007ffff45310d5 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007ffff45310d5 in __GI_raise (sig=<optimized out>)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007ffff453483b in __GI_abort () at abort.c:91
#2  0x00007ffff4e8969d in __gnu_cxx::__verbose_terminate_handler() ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff4e87846 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff4e87873 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff4e879b6 in __cxa_rethrow () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007ffff2e8b16c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#7  0x00007ffff2e8ff67 in QCoreApplication::exec() () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#8  0x00007ffff7a26749 in octave_start_gui (argc=10, argv=0x7fffffffc928, start_gui=false)
    at libgui/src/octave-gui.cc:201
#9  0x0000000000402dc0 in main (argc=10, argv=0x7fffffffc928) at src/main-gui.cc:43

Rik <rik5>
Project Administrator

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #35526:  bad_plot.m added by rik5 (204B - d2l/unknowntype)

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by dastew (Posted a comment)
  • -email is unavailable- added by lachlan (Posted a comment)
  • -email is unavailable- added by avinoam (Posted a comment)
  • -email is unavailable- added by rik5 (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 project members can vote.

     

     

     

     

    Follow 14 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-08-08 rik5 StatusReady For Test => Fixed
        Open/ClosedOpen => Closed
    2016-07-28 jwe StatusPatch Submitted => Ready For Test
        Assigned tolachlan => jwe
    2016-07-15 lachlan Attached File- => Added bug_46501_uimenu_crash.v1.cset, #37886
    2016-07-01 rik5 Severity3 - Normal => 4 - Important
    2016-06-29 lachlan Attached File- => Added bug_46501_uimenu_crash.cset, #37622
        StatusConfirmed => Patch Submitted
        Assigned toNone => lachlan
    2016-06-21 lachlan Dependencies- => bugs #48273 is dependent
    2015-11-24 rik5 Dependencies- => Depends on bugs #44339
    2015-11-24 rik5 StatusNone => Confirmed
    2015-11-23 rik5 Dependencies- => Depends on bugs #44875
    2015-11-23 rik5 Attached File- => Added bad_plot.m, #35526

    Back to the top


    Powered by Savane 3.9