Skip to content

Commit

Permalink
proc: unlock OS thread on exit from handlePtraceFuncs
Browse files Browse the repository at this point in the history
On FreeBSD and OpenBSD, the use of runtime.LockOSThread is resulting in segfaults
within the Go runtime (see golang/go#52394) - while it
should not be necessary, calling runtime.UnlockOSThread upon exit from
handlePtraceFuncs avoids this issue and allows the tests to run correctly.
  • Loading branch information
4a6f656c committed Apr 21, 2022
1 parent 3138157 commit a91562b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/proc/native/proc.go
Expand Up @@ -271,6 +271,13 @@ func (dbp *nativeProcess) handlePtraceFuncs() {
// all commands after PTRACE_ATTACH to come from the same thread.
runtime.LockOSThread()

// Leaving the OS thread locked currently leads to segfaults in the
// Go runtime while running on FreeBSD and OpenBSD:
// https://github.com/golang/go/issues/52394
if runtime.GOOS == "freebsd" || runtime.GOOS == "openbsd" {
defer runtime.UnlockOSThread()
}

for fn := range dbp.ptraceChan {
fn()
dbp.ptraceDoneChan <- nil
Expand Down

0 comments on commit a91562b

Please sign in to comment.