Skip to content
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

Latest commit breaks luakit (phantom object pushed to stack?) #991

Closed
PluMGMK opened this issue Apr 29, 2023 · 3 comments
Closed

Latest commit breaks luakit (phantom object pushed to stack?) #991

PluMGMK opened this issue Apr 29, 2023 · 3 comments

Comments

@PluMGMK
Copy link

PluMGMK commented Apr 29, 2023

Hello! The latest commit (1c27912) "somehow" results in an extra object being pushed on the stack during some startup code in the luakit browser. As documented at luakit/luakit#1040, this breaks the code in luakit that sets packages.path, since this code uses absolute stack positions instead of relative offsets. The presence of an extra object on the stack causes all these absolute positions to be off by one, so the code fails.

I'm not sure what this extra object is, it seems to be an empty table…

@MikePall
Copy link
Member

While the original code in luaH_add_paths certainly isn't very modular, the fix is just hiding a bigger problem in the luakit codebase.
The change in LuaJIT is purely about handling finalizers (__gc function for userdata) that throw errors. Which is a really, really bad idea and invoking undefined behavior.
The corollary is then, luakit apparently has a finalizer, which throws an error during startup. You should see ERROR in finalizer: ... on stderr (with the current LuaJIT). Fix that and find out why it was previously silently swallowed by some pcall and/or some code was skipped unintentionally (that now leaves the table on the stack).

@PluMGMK
Copy link
Author

PluMGMK commented Apr 30, 2023

Thanks for the quick response! I don't see anything like that in stderr though:

[    0.110633] I [core/luah]: Loading rc: /home/mgkeyes/.config/luakit/rc.lua
[    0.121024] I [lua/adblock]: found 2 filter lists
[    0.466906] I [lua/styles]: found 2 user stylesheets
[    4.653647] I [lua/webview]: Requested link: https://lfs.koddos.net/blfs/view/systemd/xsoft/tigervnc.html (text/html)

(WebKitWebProcess:15023): GLib-WARNING **: 11:43:46.913: Invalid file descriptor.

(WebKitWebProcess:15255): GLib-CRITICAL **: 11:43:46.913: g_io_channel_write_chars: assertion 'channel != NULL' failed

(WebKitWebProcess:15255): GLib-CRITICAL **: 11:43:46.913: g_io_channel_write_chars: assertion 'channel != NULL' failed

<way more of these GLib-CRITICAL lines as all my tabs shut down when I close the browser normally>

@MikePall
Copy link
Member

Oh, I found it. That table was from the setup code for the finalizer error reporting. I've fixed that now.
Thanks for the report!

BTW: Fixing the assumption in luaH_add_paths about the stack layout of the calling environment would still be a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants