Skip to content

Commit

Permalink
proc/gdbserial/gdbserver: Don't pass DYLD_INSERT_LIBRARIES to debugse…
Browse files Browse the repository at this point in the history
…rver (go-delve#3181)

Filter out DYLD_INSERT_LIBRARIES on Darwin when launching debugserver.
This is needed since macOS Ventura, loading custom dylib into debugserver
using DYLD_INSERT_LIBRARIES leads to a crash.
This is unlike other protected processes, where they just strip it out.
  • Loading branch information
aviramha authored Nov 7, 2022
1 parent cba16f9 commit 350dd6a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/proc/gdbserial/gdbserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,17 @@ func LLDBLaunch(cmd []string, wd string, flags proc.LaunchFlags, debugInfoDirs [

if runtime.GOOS == "darwin" {
process.Env = proc.DisableAsyncPreemptEnv()
// Filter out DYLD_INSERT_LIBRARIES on Darwin.
// This is needed since macOS Ventura, loading custom dylib into debugserver
// using DYLD_INSERT_LIBRARIES leads to a crash.
// This is unlike other protected processes, where they just strip it out.
env := make([]string, 0, len(process.Env))
for _, v := range process.Env {
if !(v == "DYLD_INSERT_LIBRARIES") {
env = append(env, v)
}
}
process.Env = env
}

if err = process.Start(); err != nil {
Expand Down

0 comments on commit 350dd6a

Please sign in to comment.