-
Notifications
You must be signed in to change notification settings - Fork 465
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
[BUG] node REPL crashes creating ObjectWrap in getter #1000
Comments
There seem to be two issues here:
This is reminiscent of Python's "while handling the original error, another error occurred" message. |
There are several problems in the case:
Please let me know if there are any other conditions that may apply. I'll submit patches shortly. |
Should this be closed now that nodejs/node#38798 is landed? |
@trxcllnt could you verify if the fix landed has addressed your issue? |
@mhdawson is there a build of v16.4.0 I can try? I'm not set up to build node at the moment. |
@trxcllnt these are the nightly builds for master: https://nodejs.org/download/nightly/v17.0.0-nightly20210616767996047c/ I think that would like be the best place to test as 16.4 is not out yet. I do see it in the release proposal though: nodejs/node#39031 and the target for v16.4.0 shows as 15 June (nodejs/Release#658) so it may be coming soon. |
@danielleadams thanks for the update :) |
Not resolved in node v16.4.0: $ node
Welcome to Node.js v16.4.0.
Type ".help" for more information.
> var b = new (require('./build/Debug/crash_repro.node')).Bar()
undefined
> b.gFATAL ERROR: Error::Error napi_create_reference
1: 0xb200e0 node::Abort() [node]
2: 0xa3c157 node::FatalError(char const*, char const*) [node]
3: 0xa3c160 [node]
4: 0xaeb7ab napi_fatal_error [node]
5: 0x7f19189d0a4e Napi::ObjectReference::~ObjectReference() [/home/ptaylor/dev/node-addon-cmake-js-sandbox/build/Debug/crash_repro.node]
6: 0x7f19189d0b14 Napi::Error::Error(napi_env__*, napi_value__*) [/home/ptaylor/dev/node-addon-cmake-js-sandbox/build/Debug/crash_repro.node]
7: 0x7f19189d097f Napi::Error::New(napi_env__*) [/home/ptaylor/dev/node-addon-cmake-js-sandbox/build/Debug/crash_repro.node]
8: 0x7f19189d0758 Napi::Function::New(unsigned long, napi_value__* const*) const [/home/ptaylor/dev/node-addon-cmake-js-sandbox/build/Debug/crash_repro.node]
9: 0x7f19189d06d9 Napi::Function::New(std::initializer_list<napi_value__*> const&) const [/home/ptaylor/dev/node-addon-cmake-js-sandbox/build/Debug/crash_repro.node]
10: 0x7f19189d13a8 Napi::FunctionReference::New(std::initializer_list<napi_value__*> const&) const [/home/ptaylor/dev/node-addon-cmake-js-sandbox/build/Debug/crash_repro.node]
11: 0x7f19189d250d Bar::get_new_foo(Napi::CallbackInfo const&) [/home/ptaylor/dev/node-addon-cmake-js-sandbox/build/Debug/crash_repro.node]
12: 0x7f19189cfb65 [/home/ptaylor/dev/node-addon-cmake-js-sandbox/build/Debug/crash_repro.node]
13: 0x7f19189cfc39 [/home/ptaylor/dev/node-addon-cmake-js-sandbox/build/Debug/crash_repro.node]
14: 0x7f19189cfbfd [/home/ptaylor/dev/node-addon-cmake-js-sandbox/build/Debug/crash_repro.node]
15: 0xaceebf [node]
16: 0x15dbdcc [node]
Aborted |
@trxcllnt thanks for the update. Seems like we've only fixed one of the several issues that @legendecas mentioned. I think we discussed options that are related to this issue in the Node-api team meeting today. |
This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made. |
I tried running the addon with changes in PR #1075. I now have a new fatal error inside Also Edit: And the error is |
After doing some testing, it looks like the |
Sorry for spamming this issue, but I did more experiments with this particular addon and found that if we execute I am not very familiar with how REPL or V8 work under the hood, but this is what I've found so far. |
@JckXia hey, since you say that copy-pasting the single line code to the REPL didn't cause the crash, I have to mention that the error v8 thrown internally is that v8 is detecting if the native method is side-effect-free and if Node.js REPL is safe to invoke the method for previews. So let's say when you typed
The mechanism v8 use to detect if a native method is side-effect-free is to disallowing javascript executions when invoking the native method. So back to the issue, when you type So the problem only occurs when you type in the REPL. Script mode and copy-paste a full script source text into the REPL won't trigger the crash. |
We will relook at this issue when #1075 lands |
#1075 has landed, but we still see an error in the define properties as JavaScript execution is not allowed. @legendecas clarified that it is because the Repl tries to Next step is to dig a bit deeper into why the method is still being called. @legendecas will try to do that. |
@JckXia mentioned that it seems not to happen with the main branch from ~ 1 month ago. It might make sense to bisect to see where it potentially got "fixed" to see what changed between the good/back versions. |
Did a quick version bisection. It looks like the node version upgrade from v16.5.0 to v16.6.0 "fixes" this bug. https://github.com/nodejs/node/releases/tag/v16.6.0 |
Discussed in the Node-api team meeting today. Next step would seem to be to figure out which of the commits in https://github.com/nodejs/node/releases/tag/v16.6.0 fixes the issue and if it makes any sense to backport that to the 14.x release line (12.x goes EOL in April and so it may not be worth backporting to there) |
@legendecas mentioned he might find some time to look at the commits between those two and figure out which one seems to fix the issue. |
Hey guys. It looks like the commit nodejs/node@6114198717 fixes the issue. It looks like a V8 ver upgrade as expected. |
I can confirm https://chromium-review.googlesource.com/c/v8/v8/+/2857634 fixed calling side-effect accessors on side-effect-free debug-evaluate call. (manually picked the patch on v14.x locally to test out) I'm not sure what the policy is of backporting v8 patches. Since this patch does not break ABI, I'd believe we can safely land the patch on v12.x and v14.x lines (with conflicts resolved, apparently there are lots of conflicts). |
Hey everyone. I did some work for backporting this commit(https://chromium-review.googlesource.com/c/v8/v8/+/2857634) and have some questions. After patching it onto v14.x staging and trying to build node with make, I got a few compilation errors. But one of the more notable ones is "LoadPropertyFromDictionary is not defined within scope". After doing more digging it looks like this change was introduced by v8/v8@8d62d4b#diff-b2526928b4a5ecbf4274ccb91d3a2114e9ae3638f4ca0b66a57f1a0adcda6fb7R21-R27, and the If we were to backport the changes in https://chromium-review.googlesource.com/c/v8/v8/+/2857634, would we have to backport the aforementioned changes with swiss-name-dictionary as well? Thanks. |
Discussed in the Node-api team meeting today. Gabriel confirmed based on past experience that we need to pull in dependent changes. Likelihood being accepted for 14.x will depend on how bid the change ends up being. |
Based on investigation/discussion it looks like the change will be too risky for 14x. It's fixed in 16.x and current plan is to leave it at that. Going to close this issue, please let us know if that was not the right thing to do. |
The node REPL seems to crash if a C++ getter creates an instance of a class that extends
ObjectWrap
.This works in a script, but it crashes as soon as the REPL's auto-complete attempts to "preview"
bar.get_new_foo
:The text was updated successfully, but these errors were encountered: