GNOME Bugzilla – Bug 741859
Assertion while creating an extension
Last modified: 2017-03-25 04:30:38 UTC
During the multiple-threads/global-loaders test an assertion is sometimes triggered: _lua_pushinstance: assertion failed: (lua_touserdata (L, -1) == instance) It seems to always happen during: _lua_pushinstance (L, "GObject", "Object", the_type, object) However, the LGI lock is protecting the call. It must be getting released at some point.
So the issue seems to be that during _lua_pushinstance() another thread runs Lua code because the lock is released at[1]. This is then corrupting the stack and the assertion that lua_instance._native == instance fails. 1. https://github.com/pavouk/lgi/blob/master/lgi/override/GObject-Object.lua#L61
Reopened the LGI bug that added the enter()/leave() functions. There also seems to be issues with callbacks. Adding a GLib.idle_add() to update_state and calling it in the thread handler causes panics, SEGV and assertions.
Created attachment 293487 [details] [review] Fix the global Lua plugin loader with multiple threads LGI will yield to other threads when calling into C API. This caused the return values for another thread's function call to be on the Lua stack which caused an assertion. This also adds multiple assertions that the thread's Lua stack does not have any unpopped values.