After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 741859 - Assertion while creating an extension
Assertion while creating an extension
Status: RESOLVED FIXED
Product: libpeas
Classification: Platform
Component: lua
git master
Other Linux
: Normal normal
: ---
Assigned To: libpeas-maint
libpeas-maint
Depends on:
Blocks:
 
 
Reported: 2014-12-22 14:11 UTC by Garrett Regier
Modified: 2017-03-25 04:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix the global Lua plugin loader with multiple threads (5.35 KB, patch)
2014-12-30 17:47 UTC, Garrett Regier
committed Details | Review

Description Garrett Regier 2014-12-22 14:11:04 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.
Comment 1 Garrett Regier 2014-12-22 21:39:25 UTC
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
Comment 2 Garrett Regier 2014-12-22 21:50:11 UTC
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.
Comment 3 Garrett Regier 2014-12-30 17:47:55 UTC
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.