Skip to content

Instantly share code, notes, and snippets.

@suzuki-shunsuke
Created November 11, 2021 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suzuki-shunsuke/205719236a467ce3d848f6605f79941b to your computer and use it in GitHub Desktop.
Save suzuki-shunsuke/205719236a467ce3d848f6605f79941b to your computer and use it in GitHub Desktop.
os/exec SIGABORT
package foo
func Foo() {}
package foo
import (
"os/exec"
"testing"
)
func TestFoo(t *testing.T) {
cmd := exec.Command("true")
if err := cmd.Start(); err != nil {
t.Fatal(err)
}
if err := cmd.Wait(); err != nil {
t.Fatal(err)
}
}
$ go test -race .
SIGABRT: abort
PC=0x7ff81fe5e112 m=0 sigcode=0
goroutine 0 [idle]:
syscall.rawSyscall(0x10b7960, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.17.2/libexec/src/runtime/sys_darwin.go:77 +0x47 fp=0xc0000467e8 sp=0xc0000467c8 pc=0x10a56a7
syscall.rawSyscall(0x10ab565, 0x0, 0x0, 0x1)
<autogenerated>:1 +0x26 fp=0xc000046830 sp=0xc0000467e8 pc=0x10abc86
syscall.forkAndExecInChild(0xc0000aa1b2, {0xc00009c500, 0x2, 0x0}, {0xc0000ec000, 0x3f, 0x1000}, 0x0, 0x0, 0xc000046b38, ...)
/usr/local/Cellar/go/1.17.2/libexec/src/syscall/exec_libc2.go:80 +0xed fp=0xc0000468c0 sp=0xc000046830 pc=0x10b386d
syscall.forkExec({0xc0000aa163, 0xd}, {0xc00009c4e0, 0x1, 0x1}, 0xc000046b38)
/usr/local/Cellar/go/1.17.2/libexec/src/syscall/exec_unix.go:212 +0x5a7 fp=0xc000046a58 sp=0xc0000468c0 pc=0x10b4907
syscall.StartProcess(...)
/usr/local/Cellar/go/1.17.2/libexec/src/syscall/exec_unix.go:264
os.startProcess({0xc0000aa163, 0xd}, {0xc00009c4e0, 0x1, 0x1}, 0xc000046dc8)
/usr/local/Cellar/go/1.17.2/libexec/src/os/exec_posix.go:55 +0x526 fp=0xc000046b90 sp=0xc000046a58 pc=0x10d1f46
os.StartProcess({0xc0000aa163, 0xd}, {0xc00009c4e0, 0x1, 0x1}, 0xc0000aa163)
/usr/local/Cellar/go/1.17.2/libexec/src/os/exec.go:109 +0x7a fp=0xc000046bf0 sp=0xc000046b90 pc=0x10d191a
os/exec.(*Cmd).Start(0xc0000dc000)
/usr/local/Cellar/go/1.17.2/libexec/src/os/exec/exec.go:422 +0x9d4 fp=0xc000046e20 sp=0xc000046bf0 pc=0x1185354
foo.TestFoo(0xc000083a00)
/Users/shunsuke-suzuki/Documents/test/golang/exec/race/foo_test.go:10 +0x49 fp=0xc000046e98 sp=0xc000046e20 pc=0x1187169
testing.tRunner(0xc000083a00, 0x11c2518)
/usr/local/Cellar/go/1.17.2/libexec/src/testing/testing.go:1259 +0x230 fp=0xc000046fb0 sp=0xc000046e98 pc=0x1123cd0
testing.(*T).Run·dwrap·21()
/usr/local/Cellar/go/1.17.2/libexec/src/testing/testing.go:1306 +0x48 fp=0xc000046fe0 sp=0xc000046fb0 pc=0x1125268
runtime.goexit()
/usr/local/Cellar/go/1.17.2/libexec/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc000046fe8 sp=0xc000046fe0 pc=0x10a8a81
created by testing.(*T).Run
/usr/local/Cellar/go/1.17.2/libexec/src/testing/testing.go:1306 +0x727
goroutine 21 [running]:
runtime.systemstack_switch()
/usr/local/Cellar/go/1.17.2/libexec/src/runtime/asm_amd64.s:350 fp=0xc000046798 sp=0xc000046790 pc=0x10a6840
runtime.libcCall(0x18, 0x12d56e0)
/usr/local/Cellar/go/1.17.2/libexec/src/runtime/sys_libc.go:49 +0x66 fp=0xc0000467c8 sp=0xc000046798 pc=0x1096126
syscall.rawSyscall(0x10b7960, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.17.2/libexec/src/runtime/sys_darwin.go:77 +0x47 fp=0xc0000467e8 sp=0xc0000467c8 pc=0x10a56a7
syscall.rawSyscall(0x10ab565, 0x0, 0x0, 0x1)
<autogenerated>:1 +0x26 fp=0xc000046830 sp=0xc0000467e8 pc=0x10abc86
syscall.forkAndExecInChild(0xc0000aa1b2, {0xc00009c500, 0x2, 0x0}, {0xc0000ec000, 0x3f, 0x1000}, 0x0, 0x0, 0xc000046b38, ...)
/usr/local/Cellar/go/1.17.2/libexec/src/syscall/exec_libc2.go:80 +0xed fp=0xc0000468c0 sp=0xc000046830 pc=0x10b386d
syscall.forkExec({0xc0000aa163, 0xd}, {0xc00009c4e0, 0x1, 0x1}, 0xc000046b38)
/usr/local/Cellar/go/1.17.2/libexec/src/syscall/exec_unix.go:212 +0x5a7 fp=0xc000046a58 sp=0xc0000468c0 pc=0x10b4907
syscall.StartProcess(...)
/usr/local/Cellar/go/1.17.2/libexec/src/syscall/exec_unix.go:264
os.startProcess({0xc0000aa163, 0xd}, {0xc00009c4e0, 0x1, 0x1}, 0xc000046dc8)
/usr/local/Cellar/go/1.17.2/libexec/src/os/exec_posix.go:55 +0x526 fp=0xc000046b90 sp=0xc000046a58 pc=0x10d1f46
os.StartProcess({0xc0000aa163, 0xd}, {0xc00009c4e0, 0x1, 0x1}, 0xc0000aa163)
/usr/local/Cellar/go/1.17.2/libexec/src/os/exec.go:109 +0x7a fp=0xc000046bf0 sp=0xc000046b90 pc=0x10d191a
os/exec.(*Cmd).Start(0xc0000dc000)
/usr/local/Cellar/go/1.17.2/libexec/src/os/exec/exec.go:422 +0x9d4 fp=0xc000046e20 sp=0xc000046bf0 pc=0x1185354
foo.TestFoo(0xc000083a00)
/Users/shunsuke-suzuki/Documents/test/golang/exec/race/foo_test.go:10 +0x49 fp=0xc000046e98 sp=0xc000046e20 pc=0x1187169
testing.tRunner(0xc000083a00, 0x11c2518)
/usr/local/Cellar/go/1.17.2/libexec/src/testing/testing.go:1259 +0x230 fp=0xc000046fb0 sp=0xc000046e98 pc=0x1123cd0
testing.(*T).Run·dwrap·21()
/usr/local/Cellar/go/1.17.2/libexec/src/testing/testing.go:1306 +0x48 fp=0xc000046fe0 sp=0xc000046fb0 pc=0x1125268
runtime.goexit()
/usr/local/Cellar/go/1.17.2/libexec/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc000046fe8 sp=0xc000046fe0 pc=0x10a8a81
created by testing.(*T).Run
/usr/local/Cellar/go/1.17.2/libexec/src/testing/testing.go:1306 +0x727
goroutine 1 [chan receive]:
testing.(*T).Run(0xc000083860, {0x11b8a06, 0x7}, 0x11c2518)
/usr/local/Cellar/go/1.17.2/libexec/src/testing/testing.go:1307 +0x752
testing.runTests.func1(0x0)
/usr/local/Cellar/go/1.17.2/libexec/src/testing/testing.go:1598 +0x9a
testing.tRunner(0xc000083860, 0xc0000bbbf8)
/usr/local/Cellar/go/1.17.2/libexec/src/testing/testing.go:1259 +0x230
testing.runTests(0xc0000d4000, {0x12cd210, 0x1, 0x1}, {0x0, 0x56fffff, 0x12d52c0})
/usr/local/Cellar/go/1.17.2/libexec/src/testing/testing.go:1596 +0x7cb
testing.(*M).Run(0xc0000d4000)
/usr/local/Cellar/go/1.17.2/libexec/src/testing/testing.go:1504 +0x9d2
main.main()
_testmain.go:43 +0x22c
rax 0x0
rbx 0x613a600
rcx 0x7ff7bfefe8b8
rdx 0x0
rdi 0x303
rsi 0x6
rbp 0x7ff7bfefe8e0
rsp 0x7ff7bfefe8b8
r8 0x0
r9 0x0
r10 0x0
r11 0x246
r12 0x303
r13 0x50
r14 0x6
r15 0x16
rip 0x7ff81fe5e112
rflags 0x246
cs 0x7
fs 0x0
gs 0x0
--- FAIL: TestFoo (0.01s)
foo_test.go:14: exit status 2
FAIL
FAIL foo 0.296s
FAIL
$ go test .
ok foo (cached)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment