-
Notifications
You must be signed in to change notification settings - Fork 4
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 on process shutdown with vm.createContext #31
Comments
Ohhh yeah.
...which I still don't understand, but I read as... the fiddling with refs is making us try and finalize something twice, and then we would be triggering the double free? I don't see where n-api is deciding the refcounts are wrong, and I also don't understand ObjectInfo's fiddling of refcounts in the constructor, so I'm quite stuck. |
Sigh … yeah, at first look this seems like a bug in N-API to me. The reference counting semantics for it are generally very unclear – nodejs/node#35777 may or may not be related to this, so it might be worth trying to see what happens for different Node.js versions. |
I bisected this down to nodejs/node@53ca0b9 / nodejs/node#28428 Merged just before 12 went LTS, which explains why I thought this had happened "forever"; we only run LTSes.
I also accidentally found that ASAN isn't happy with this, which seems like it might be related.
|
This code causes node to segfault on exit.
Sometimes(:tm:) you can fix this by adding
global.gc()
before the script exits, but that's defeatable, e.g. with this, which segfaults again:The backtrace is meaningless to me; it's trying to clean up the environment and it's trying a double-free. Ooh, I wonder if ASAN will catch this? Note that the backtrace is way worse on older nodes.
Debug node built is from HEAD today (d90fa196c5540109bf9c5063f8c51673340ad9e3). Ubuntu 20.10, amd64.
I found this trying to diagnose jestjs/jest#10289 ; this
createContext
/runInContext
dance is how Jest works. However, I assume Jest works for most people most of the time, so it can't always segfault. As far as I can see, Jest always useScript
to load user code, with most core modulesrequire
'd like in the second bit of code.The text was updated successfully, but these errors were encountered: