Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upsrc: disallow calling env-dependent methods during bootstrap #27234
Conversation
This comment has been minimized.
This comment has been minimized.
nodejs-github-bot
added
the
C++
label
Apr 15, 2019
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
joyeecheung
added
review wanted
process
labels
Apr 15, 2019
joyeecheung
added
author ready
and removed
review wanted
labels
Apr 15, 2019
|
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?). |
This comment has been minimized.
This comment has been minimized.
|
@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. |
This comment has been minimized.
This comment has been minimized.
|
Is |
This comment has been minimized.
This comment has been minimized.
|
@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. |
This comment has been minimized.
This comment has been minimized.
|
Landed in 83d1ca7 |
joyeecheung commentedApr 15, 2019
•
edited
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