-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
build: always use V8_ENABLE_CHECKS in debug mode #12029
Conversation
Define `V8_ENABLE_CHECKS` in `common.gypi` for the debug mode. Without this, these checks would only be present in the object files generated from the V8 build, and so for inline functions in v8.h multiple different definitions could be generated, where one definition includes the check and the other does not. Refs: nodejs#11975 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. This doesn't change the API or ABI as far as I know so it could, in theory, land in the release branches.
I'm good with landing it in the release branches but let's wait just a bit with it sitting in master and in the 8.0.0 release before doing so, just to be on the safe side. |
I don’t think anything in the CI is related to this PR, but here’s another run just to be sure: @bnoordhuis @jasnell Do the |
I'm not sure actually. |
It does (but see nodejs/node-gyp#1118.) It's still API/ABI-neutral though. |
If it is included by addons, then it could cause some addons to break in debug mode where they worked before. |
Yes, but only if they were already broken, only silently. |
Not necessarily. There are some operations that seem to behave perfectly fine without the checks enabled, but then will throw fatal errors with the checks enabled. For example, in the N-API PR we had code similar to this: if (value->IsNumber()) {
return value.As<v8::Int32>()->Value();
} I was surprised when @addaleax pointed out that could crash in debug mode, because it was working fine in my release and debug builds on Windows, even when the number value was not an Int32. That's how I found this bug with |
I hope we can agree the code in your example is defective: not all numbers are int32s.
Hence my point: this only affects add-ons that are already broken - and only when rebuilding from source and in debug mode. I don't see a reason not to land this in the release branches. |
It does turn a silent failure into a loud one, for JS exceptions we’d consider that semver-major. I’m also pretty sure there might be code that relies on such casts not crashing – for example, 0d290a2 fixed such a bug in our own codebase. I agree that debug mode is going to make problems coming out of this exceptionally rare, but I’m still inclined to agree with @jasongin in that this maybe should not make it to other release branches (or maybe not LTS, at least). |
Landed in c68da89. @bnoordhuis If you feel really strongly about this just pull the dont-land labels here. :) |
Define `V8_ENABLE_CHECKS` in `common.gypi` for the debug mode. Without this, these checks would only be present in the object files generated from the V8 build, and so for inline functions in v8.h multiple different definitions could be generated, where one definition includes the check and the other does not. Refs: #11975 (comment) PR-URL: #12029 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jason Ginchereau <[email protected]> Reviewed-By: Hitesh Kanwathirtha <[email protected]>
Define
V8_ENABLE_CHECKS
incommon.gypi
for the debug mode.Without this, these checks would only be present in the object files
generated from the V8 build, and so for inline functions in v8.h
multiple different definitions could be generated, where one definition
includes the check and the other does not.
Refs: #11975 (comment)
/cc @jasongin @bnoordhuis @danbev