-
Notifications
You must be signed in to change notification settings - Fork 11
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
Prevent issues with stacks exactly 11 deep #16
Conversation
I was seeing `panic serving 10.40.243.118:44663: runtime error: index out of range` `/tmp/build_c0c3d66e-c25b-42a1-9bf2-a77b92b2f44c/.vendor/src/github.com/github/go-opstocat/haystack.go:36 +0x65a` when attempting to report an exception via grohl + go-opstocat. [haystack.go:36](https://github.com/github/go-opstocat/blob/7faea155fd76d1c43f9dd30622664674586cbbc1/haystack.go#L36) attempts to grab the first frame in the backtrace, but apparently the slice was empty! I found this bit of code which, as it was previously written, returns an empty slice if the stack is exactly 11 frames deep. I think the intention was to always grab the top 10 stack frames; if so, I think it can be rewritten like this. Reminder that go's slice range indices are exclusive: `[0:10]` means grab elements 0 through 9.
return all | ||
} else { | ||
return all[10 : len(all)-1] | ||
return all[0:10] |
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 old code starts at index 10 and went to the end. I don't remember why it needed to skip the first 10 lines though.
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.
Should we just preserve the entire backtrace?
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 think it had to do with the first 10 lines being the same in every trace, or something. But yeah maybe preserving all of them is the best thing to do.
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'm kinda leaning toward that the more I think about it. If I change it to just return all
, is that 👍 with you?
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.
Yup!
OK, ready for some 👀 |
Had a minor test failure. Also cleaned stuff a bit more. Removing the need to count to 11 simplifies things a bit :) |
Prevent issues with stacks exactly 11 deep
I was seeing
panic serving 10.40.243.118:44663: runtime error: index out of range
/tmp/build_c0c3d66e-c25b-42a1-9bf2-a77b92b2f44c/.vendor/src/github.com/github/go-opstocat/haystack.go:36+0x65a
when attempting to report an exception via grohl + go-opstocat.haystack.go:36 attempts to grab the first frame in the backtrace, but apparently the slice was empty!
I found this bit of code which, as it was previously written, returns an empty slice if the stack is exactly 11 frames deep.
I think the intention was to always grab the top 10 stack frames; if so, I think it can be rewritten like this. Reminder that go's slice range indices are exclusive:
[0:10]
means grab elements 0 through 9./cc: @technoweenie