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

fix panicwrap parent check (#6264) #6299

Merged
merged 1 commit into from
Aug 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions x/sentry_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,17 @@ func WrapPanics() {
if err != nil {
panic(err)
}
// If exitStatus >= 0, then we're the parent process and the panicwrap
// re-executed ourselves and completed. Just exit with the proper status.
if exitStatus >= 0 {

// Note: panicwrap.Wrap documentation states that exitStatus == -1
// should be used to determine whether the process is the child.
// However, this is not reliable. See https://github.com/mitchellh/panicwrap/issues/18
// we have found that exitStatus = -1 is returned even when
// the process is the parent. Likely due to panicwrap returning
// syscall.WaitStatus.ExitStatus() as the exitStatus, which _can_ be
// -1. Checking panicwrap.Wrapped(nil) is more reliable.
if !panicwrap.Wrapped(nil) {
// parent
os.Exit(exitStatus)
}
// child
}