Skip to content
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

Merged
merged 5 commits into from
Aug 7, 2014

Conversation

alindeman
Copy link
Collaborator

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

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]
Copy link
Owner

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.

Copy link
Collaborator Author

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?

Copy link
Owner

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.

Copy link
Collaborator Author

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?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup!

@alindeman
Copy link
Collaborator Author

OK, ready for some 👀

@technoweenie
Copy link
Owner

Had a minor test failure. Also cleaned stuff a bit more. Removing the need to count to 11 simplifies things a bit :)

technoweenie added a commit that referenced this pull request Aug 7, 2014
Prevent issues with stacks exactly 11 deep
@technoweenie technoweenie merged commit 2bcb53d into master Aug 7, 2014
@technoweenie technoweenie deleted the one-for-the-record-books branch August 7, 2014 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants