-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
inspector: split the HostPort being used and the one parsed from CLI #24772
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
Conversation
src/inspector_js_api.cc
Outdated
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.
The cast can overflow. Better to check that args[0]->IsInt32() and that args[0]->Int32Value() > 0.
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.
It was already possible to overflow before since we were assigning uint32_t to int anyways. I think we'd better turn port into a uint16_t (see the TODO in node_options.h) and do the checks whenever we set it, but I'd prefer to do that in another patch, because the port is actually settable from user land so there will be a more obvious behavior change than in this patch. (I am also thinking about using gsl::narrow to do it but we will need to introduce GSL as a dependency first...or maybe we can simply mask that with 0xffff)
src/node_process.cc
Outdated
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.
Unnecessary cast, right?
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.
I guess it's better to be explicit than implicit? Also I plan to turn this into a uint16_t in the future - I think that's also where things like GSL (see #23821) may be useful
src/inspector_agent.h
Outdated
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.
It's kind of gnarly to have those fields duplicated. Can that be fixed somehow?
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.
I've tried a few approaches, e.g. splitting the options into two Options subclasses instead of putting them in one DebugOptions, that makes the parsing code even more complicated because we have combined arguments like --inspect-brk=127.0.0.1:0. Also, the HostPort in DebugOptions are actually per-process (because those are parsed from CLI) whereas the shared HostPort are per-Environment (since the inspector agents are per-Environment). Conceptually, they are not really duplicates because the CLI ones are "snapshots" of the parsed arguments which may still be useful themselves (e.g. in tests)
|
Removed the unnecessary per-process lock in |
|
Added a few compile-time switches to make it build when inspector is not enabled (like before, that will result in all the debug options being default..I wonder whether we want to just eliminate them all in the future). CI: https://ci.nodejs.org/job/node-test-pull-request/19164/ |
|
@joyeecheung Looks like this might need a rebase? |
d926a7c to
80abade
Compare
|
Resume Build CI: https://ci.nodejs.org/job/node-test-pull-request/19198/ ✔️ |
Instead of using a shared pointer of the entire debug option set,
pass the parsed debug option to inspector classes by value because
they are set once the CLI argument parsing is done. Add another shared
pointer to HostPort being used by the inspector server, which is copied
from the one in the debug options initially. The port of the shared
HostPort is 9229 by default and can be specified as 0 initially but
will be set to the actual port of the server once it starts listening.
This makes the shared state clearer and makes it possible to use
`require('internal/options')` in JS land to query the CLI options
instead of using `process._breakFirstLine` and other underscored
properties of `process` since we are now certain that these
values should not be altered once the parsing is done and can be
passed around in copies without locks.
80abade to
c631a1a
Compare
|
Rebased. CI:https://ci.nodejs.org/job/node-test-pull-request/19288/ This needs one more approval to land. Can I have some reviews please? @nodejs/v8-inspector @nodejs/process @nodejs/build-files |
|
Resume: https://ci.nodejs.org/job/node-test-pull-request/19332/ (Only failure in the previous CI run was #24403 , though) |
|
Landed in 61a8963 |
Instead of using a shared pointer of the entire debug option set,
pass the parsed debug option to inspector classes by value because
they are set once the CLI argument parsing is done. Add another shared
pointer to HostPort being used by the inspector server, which is copied
from the one in the debug options initially. The port of the shared
HostPort is 9229 by default and can be specified as 0 initially but
will be set to the actual port of the server once it starts listening.
This makes the shared state clearer and makes it possible to use
`require('internal/options')` in JS land to query the CLI options
instead of using `process._breakFirstLine` and other underscored
properties of `process` since we are now certain that these
values should not be altered once the parsing is done and can be
passed around in copies without locks.
PR-URL: #24772
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Instead of using a shared pointer of the entire debug option set,
pass the parsed debug option to inspector classes by value because
they are set once the CLI argument parsing is done. Add another shared
pointer to HostPort being used by the inspector server, which is copied
from the one in the debug options initially. The port of the shared
HostPort is 9229 by default and can be specified as 0 initially but
will be set to the actual port of the server once it starts listening.
This makes the shared state clearer and makes it possible to use
`require('internal/options')` in JS land to query the CLI options
instead of using `process._breakFirstLine` and other underscored
properties of `process` since we are now certain that these
values should not be altered once the parsing is done and can be
passed around in copies without locks.
PR-URL: #24772
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Instead of using a shared pointer of the entire debug option set,
pass the parsed debug option to inspector classes by value because
they are set once the CLI argument parsing is done. Add another shared
pointer to HostPort being used by the inspector server, which is copied
from the one in the debug options initially. The port of the shared
HostPort is 9229 by default and can be specified as 0 initially but
will be set to the actual port of the server once it starts listening.
This makes the shared state clearer and makes it possible to use
`require('internal/options')` in JS land to query the CLI options
instead of using `process._breakFirstLine` and other underscored
properties of `process` since we are now certain that these
values should not be altered once the parsing is done and can be
passed around in copies without locks.
PR-URL: nodejs#24772
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Instead of using a shared pointer of the entire debug option set,
pass the parsed debug option to inspector classes by value because
they are set once the CLI argument parsing is done. Add another shared
pointer to HostPort being used by the inspector server, which is copied
from the one in the debug options initially. The port of the shared
HostPort is 9229 by default and can be specified as 0 initially but
will be set to the actual port of the server once it starts listening.
This makes the shared state clearer and makes it possible to use
require('internal/options')in JS land to query the CLI optionsinstead of using
process._breakFirstLineand other underscoredproperties of
processsince we are now certain that thesevalues should not be altered once the parsing is done and can be
passed around in copies without locks.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes