-
-
Notifications
You must be signed in to change notification settings - Fork 101
src: print stack for error objects #233
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
|
Jenkins CI: https://ci.nodejs.org/view/post-mortem/job/llnode-pipeline/31/ (first try, let's see how it goes) |
Error objects have a .stack property, which is actually an accessor. The stack is stored in a unnamed symbol property and converted to a string when .stack is accessed in JavaScript. This patch implements the accessor behavior to print the error stack when inspecting an Error object. Fixes: nodejs#218
5ed2051 to
2db870f
Compare
|
@cjihrig thank you for your review! I addressed your comments, PTAL. |
joyeecheung
left a comment
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.
Looks like the test is happy enough, so LGTM. Personally I'd prefer we use constant names instead of magic numbers, but that can be refactored later
|
|
||
| int64_t stack_len = Smi(maybe_stack_len).GetValue(); | ||
|
|
||
| int multiplier = 5; |
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.
Maybe it would be more maintainable if FrameArray::kElementsPerFrame is exposed in the post mortem metadata and gets loaded here..(not sure if that's on 6.x but it's still in TOT)
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.
Yes, I have this on my TODO list and will probably get to that at some point.
| // TODO (mmarchini): Refactor: create an StackIterator which returns | ||
| // StackFrame objects | ||
| for (int64_t i = 0; i < stack_len; i++) { | ||
| Value maybe_fn = arr.GetArrayElement(2 + (i * multiplier), err); |
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.
So this is actually kFirstIndex + i * kElementsPerFrame + kFunctionOffset right?
Error objects have a .stack property, which is actually an accessor. The stack is stored in a unnamed symbol property and converted to a string when .stack is accessed in JavaScript. This patch implements the accessor behavior to print the error stack when inspecting an Error object. Fixes: #218 PR-URL: #233 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
|
Landed in bb0d400 |
|
@mmarchini Did this make it into a release? If not would that be possible to release a version of llnode that includes this? |
|
Yes, I'll prepare a release today, which should be released in the next few days :) (Want to make sure we have a new release before #246 lands) |
|
@mmarchini I was inspecting a core dump generated from node 6.x and I was trying to get the actual stack trace for the error, and when trying to get the full stack trace with `v8 inspect -l length-of-stack-array' I constantly get a segmentation fault: Am I missing something? EDIT: I'm running llnode from latest master: |
|
Seems like a separate issue. This is not the first segfault I see in llnode (#196), we probably have some fragile code paths somewhere. Do you mind opening a new issue for this? Also, it would be nice to get llnode's stack trace right before it segfaulted. I haven't tried it, but it seems to be possible with dtrace: https://stackoverflow.com/a/17115382/2956796. |
|
@mmarchini How are users supposed to inspect the stack trace? |
|
Ohhh I see, this is a |
|
FWIW, it's working as expected on Node.js v10.13.0 (edit: and I'm also getting segfault with v6.x) |
|
Tips: you can turn on the environment variable |
I just did it 😂 Tip: to attach a debugger to the debugger, run the debugger you'll use to attach as root. |
Error objects have a .stack property, which is actually an accessor. The
stack is stored in a unnamed symbol property and converted to a string
when .stack is accessed in JavaScript. This patch implements the
accessor behavior to print the error stack when inspecting an Error
object.
Fixes: #218