-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Refactor Error.stackTraceLimit #874
Conversation
saghul
commented
Feb 1, 2025
- Store the JS value, so the conversion happens when the backtrace is needed
- Prevent recursion in build_backtrace
- Simplify code for saving / restoring exception in build_backtrace
- Store the JS value, so the conversion happens when the backtrace is needed - Prevent recursion in build_backtrace - Simplify code for saving / restoring exception in build_backtrace
@bnoordhuis PTAL, let me know what you think. It ended up a bit more complex that I originally envisioned. Alternative: convert the value on the spot and store both the JS value and the converted value, and use the latter in build_backtrace. Thoughts? |
@bnoordhuis Updated, can you PTAL one more time? |
JS_ToFloat64(ctx, &d, ctx->error_stack_trace_limit); | ||
if (isnan(d) || d < 0.0 || (isinf(d) && d < 0.0)) | ||
stack_trace_limit = 0; | ||
else if (isinf(d) || d > (double)INT32_MAX) |
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.
You don't have to cast to double (but it doesn't hurt either, it's just a no-op)
The isinf(d) && d < 0.0
two lines up looks superfluous. You check d < 0.0
first and -Infinity < 0.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.
Right. Does the same apply to checking for positive infinity? It will be larger than INT32_MAX I guess.
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.
Updated!
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.
Right. Does the same apply to checking for positive infinity? It will be larger than INT32_MAX I guess.
Good point. By an infinite amount, according to mathematicians.
JS_ToFloat64(ctx, &d, ctx->error_stack_trace_limit); | ||
if (isnan(d) || d < 0.0 || (isinf(d) && d < 0.0)) | ||
stack_trace_limit = 0; | ||
else if (isinf(d) || d > (double)INT32_MAX) |
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.
Right. Does the same apply to checking for positive infinity? It will be larger than INT32_MAX I guess.
Good point. By an infinite amount, according to mathematicians.