Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#1530 Lua: the panic handler is useless

Bug
open
nobody
None
5
2013-12-07
2013-09-28
felix
No

There is some code which doesn't work as I would like, and I don't know whom to blame, so I'm starting with you.

I use SciTE on GTK3, and I have installed LGI — bindings to the whole GLib/GObject stack for Lua. Some of the libraries included in the bindings provide asynchronous I/O by means of callbacks: a callback is passed, an appropriate hook is set up in the GLib main loop (which GTK sets up and maintains), and when the results are ready, the callback is invoked in an unprotected Lua environment. Which means that any error() in the callback results in calling the panic handler and immediate program exit, using exit() (in Lua 5.2 this changes to abort(), which is marginally more useful).

I would expect SciTE to display the message somewhere, gracefully jump back to the main event loop and continue running.

Even if the issue is to be solved at the binding or Lua level, the current Lua panic handler is not very useful. Currently it sends a message to the output pane, but since the Lua interpreter then immediately exits, the error message is never displayed anywhere.

Discussion

  • Neil Hodgson
    Neil Hodgson
    2013-09-28

    This is a deeper level of Lua than I work at so I'll leave it to others.

     
  • felix
    felix
    2013-12-07

    There are two things which can be done without meddling in Lua internals: either run the GTK main loop inside a protected environment (lua_pushcfunction() and lua_pcall()) or longjmp() from inside the panic handler to the main loop.