-
-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segfault in lua_getallocf in MemoryState::get #479
Comments
Is it possible that you loaded |
I am not sure but this might be the case. The exact execution is:
The lazy loading is done by https://github.com/folke/lazy.nvim plugin manager, and I don't think it does the loading in a coroutine. When I put
So it looks like the call is not rooted in Note that I don't get segfault in most cases, for some reason it only happens sometimes, so it might be that the call stack is different when the segfault happens. Anyway, I'll try to disable lazy-loading of |
On first load, mlua tries to obtain a It's possible that after lazy loading from non-main coroutine, it was destroyed and then reused to obtain allocation handler. Otherwise I don't see any other reasons why
I'm not sure about this. From the backtrace we can see that coroutine used to call |
…only). When mlua module is loaded from a non-main coroutine we store a reference to it to use later. If the coroutine is destroyed by GC we can pass a wrong pointer to Lua that will trigger a segfault. Instead, set main_state as Option and use current (active) state if needed. Relates to #479
Ok, thanks for the analysis. I will report back if the segfault happens again now, when I removed lazy-loading of lua-json5. Had no problems yet, but I'd wait a few days. |
Please reopen if the problem still exists. I pushed a fix already |
Hi, I am trying to track down a segfault that happens when I'm using lua-json5 plugin from Neovim. I previously described the bug here Joakker/lua-json5#5, but I am now thinking that maybe this is something with mlua itself.
Here is my latest stack traceback with debug symbols enabled:
And with variable values
It looks like it fails on
if (ud) *ud = g->allocd;
here:The exact address is a little different than in Joakker/lua-json5#5 (comment), but it looks is an offset into
global_State
which itself has address near 0:I'm also adding the contnet of
self
insidemlua::lua::Lua::create_table_from
:Do you have any idea what might be the problem? Or is it not related to mlua but something else up the stack?
The text was updated successfully, but these errors were encountered: