-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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: prevent hard coding stack trace limit #30752
Conversation
the number of frames here should already be the <= stack trace limit. as I understand it our code just provides a lower bound. |
b52d64d
to
c92a4ac
Compare
TBH this does not sound like a good idea since v8 is considering removing these non-standard APIs: https://bugs.chromium.org/p/v8/issues/detail?id=6974 By adding support in our internal error printers we are sort of encouraging people to use it - also in the case of It is especially tricky to try handling these hooks ourselves considering we also made the mistake (?) of always respecting the |
src/node_errors.cc
Outdated
MaybeLocal<Value> stack_trace_limit_val = | ||
context->Global() | ||
->Get(context, error_string) | ||
.ToLocalChecked() |
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.
This is not a valid .ToLocalChecked()
, can you handle errors here (and for the .ToChecked()
below, as @lundibundi pointed out)? Ideally, this block here would also be wrapped in a v8::TryCatch
in order to swallow these errors from trying to get the stack trace
@joyeecheung Yes, the API Anyway, if anyone has any strong opinion on this idea, it also sounds good to me if the stacktrace limit shall be referred from some internal store. |
@legendecas Adding something like |
9bf92aa
to
e6f54bb
Compare
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 LGTM although I’d have preferred the solution that reads Error.stackTraceLimit
@joyeecheung @lundibundi may I ask for your reviews on the PR since you have interests in preventing usage on the unstandardized |
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. Though I would prefer the previous Error.stackTraceLimit
version as it is useful to be able to control the C++-land stack size and to have it consistent with the JS-land. Regarding possible removal of the API, I think it is not much of an issue as this code will only be in once place and we can always replace it with a constant in a few days' time at max.
Also, the PR's name should be changed accordingly to the code.
It's true that in most cases stack trace wasn't very long to exceed the limit. Still, it is possible. |
I meant to have one function like |
543418f
to
4f1f62a
Compare
Refer to Environment::stack_trace_limit() while printing fresh stacktraces in c++ land.
4f1f62a
to
7727628
Compare
This comment has been minimized.
This comment has been minimized.
I agree with @addaleax and @lundibundi that the former solution seemed better. If the property will ever be removed, it's definitely possible to react to it appropriately. So far it's not likely that this is happening anytime soon. |
I would not oppose to a solution that allows the JS land to configure the stack trace limit, but I would be -1 if this is
|
Refer to Environment::stack_trace_limit() while printing fresh stacktraces in c++ land. PR-URL: #30752 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Landed in 8baee5e 🎉 |
Refer to Environment::stack_trace_limit() while printing fresh stacktraces in c++ land. PR-URL: #30752 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Refer to Environment::stack_trace_limit() while printing fresh stacktraces in c++ land. PR-URL: #30752 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Refer to Environment::stack_trace_limit() while printing fresh stacktraces in c++ land. PR-URL: #30752 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Refer to Environment::stack_trace_limit() while printing fresh stacktraces in c++ land. PR-URL: #30752 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Refer to Environment::stack_trace_limit() while printing fresh
stacktraces in c++ land.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes