-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
src: disallow calling env-dependent methods during bootstrap #27234
Conversation
These cannot be preserved correctly in v8 snapshot. Currently none of these are called during bootstrap, this adds assertions to make sure future contributors do not accidentally call these in the wrong time. Consider this, on the machine that builds releases: ``` process.cwd(); // "/home/iojs/build/workspace/" ``` User downloads this binary to their machine: ``` $ cd ~/ $ pwd // "/User/foo" $ node -p "process.cwd()" // "/home/iojs/build/workspace/" ``` This patch only adds checks in methods that get states from the environment - it's not likely that the setters would be called during bootstrap, and if they are called, we'll just ignore them and whatever tests that test the change would fail when snapshot is enabled. However the getters may be called in order to persist information into strings and that would be harder to catch (the test is only likely to test the format of these strings which won't be useful).
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. Would it also be sufficient to use a DCHECK instead? Our CI should at least detect these and the check does not have to be executed in the default case anymore. But I do not know if this check is expensive or not (I guess it's just a simple state check?).
@BridgeAR The check should be cheap enough, at least negligible in the context of the methods affected. Since most people do not develop with debug builds locally (I believe), using CHECK helps them discover this sooner. |
Is |
@bnoordhuis The process properties that depend on run time states (e.g. The process methods are still included in the bootstrap because the function themselves do not depend on run time states, only the results of their invocation do - I guess we could also attach the accessor properties earlier, but until we have snapshot enabled there is not much difference in terms of overhead. |
Landed in 83d1ca7 |
These cannot be preserved correctly in v8 snapshot. Currently none of these are called during bootstrap, this adds assertions to make sure future contributors do not accidentally call these in the wrong time. Consider this, on the machine that builds releases: ``` process.cwd(); # "/home/iojs/build/workspace/" ``` If `process.cwd()` is cached as in #27224, when the user downloads this binary to their machine: ``` $ cd ~/ $ pwd # "/User/foo" $ node -p "process.cwd()" # "/home/iojs/build/workspace/" ``` This patch only adds checks in methods that get states from the environment - it's not likely that the setters would be called during bootstrap, and if they are called, we'll just ignore them and whatever tests that test the change would fail when snapshot is enabled. However the getters may be called in order to persist information into strings and that would be harder to catch (the test is only likely to test the format of these strings which won't be useful). PR-URL: #27234 Refs: #27224 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
These cannot be preserved correctly in v8 snapshot. Currently
none of these are called during bootstrap, this adds assertions
to make sure future contributors do not accidentally call
these in the wrong time.
Consider this, on the machine that builds releases:
User downloads this binary to their machine:
This patch only adds checks in methods that get states from the
environment - it's not likely that the setters would be called
during bootstrap, and if they are called, we'll just ignore them
and whatever tests that test the change would fail when snapshot
is enabled. However the getters may be called in order
to persist information into strings and that would be harder
to catch (the test is only likely to test the format of these
strings which won't be useful).
Refs: #27224
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes