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:
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.