Menu

#2683 wxt: gtk-based wxt terminal does not survive int_error() while mousing

None
closed-fixed
nobody
None
2024-05-28
2024-01-25
No

Ever since the gtk version of wxWidgets moved from gtk2.8 to gtk3 the threading model of gnuplot's wxt terminal has been inconsistent with the implementation in the wx + gtk libraries. This made gnuplot error handling unreliable if the wxt terminal was active.

The problem in particular manifests when int_error() is called from inside an action triggered by a mouse event. That includes pan/zoom, 3D rotation, and hot key bindings. Gnuplot's int_error() prints an error message and then returns to top level command line processing via a LONGJMP in bail_to_command_line(). But the wx/gtk library state at the time the wxt terminal calls back into the core routines via do_event() is not clean with respect to the state originally saved for LONGJMP to return to. Thus if the operations requested by do_event() cause a core routine to exit via int_error(), a segfault from somewhere in wxt is likely to happen soon after.

Here is a simple reproducer using a hotkey triggered error:

set term wxt
bind all "B" "print 'boom?'; a = b/0."
plot sin(x)
print "Hitting 'B' as a hot key will trigger an error."
print "The program will hang, after which ^C will segfault."

Possible approaches to fixes this:

  • Repair the multithreaded variant of the gtk+wxt terminal. It has not worked for a long time.
  • Split the wxt terminal into a inboard/outboard halves, with the outboard half running in a separate process. This is the way the x11 and qt terminals work.
  • Add exception handling to the existing single-threaded wxt terminal and see if it is possible to get back to the normal command line without the current LONGJMP.

Discussion

  • Ethan Merritt

    Ethan Merritt - 2024-01-30
    • status: open --> pending-fixed
    • Group: -->
    • Priority: -->
     
  • Ethan Merritt

    Ethan Merritt - 2024-02-07

    I went with option (3) and added an exception handler that wraps event processing by the wxt terminal if it uses gtk (wxWidgets implementations on other platforms are not based on gtk).

    I was hoping that this might also fix the broken multi-threaded wxt option, but no such luck. It might be best to remove that option altogether, which would reduce the source code size by about a third and make it more readable.

     
  • Ethan Merritt

    Ethan Merritt - 2024-05-28
    • Status: pending-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB