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

cmd/link: SIGSEGV running "go run" #47816

Open
elagergren-spideroak opened this issue Aug 19, 2021 · 1 comment
Open

cmd/link: SIGSEGV running "go run" #47816

elagergren-spideroak opened this issue Aug 19, 2021 · 1 comment

Comments

@elagergren-spideroak
Copy link

@elagergren-spideroak elagergren-spideroak commented Aug 19, 2021

What version of Go are you using (go version)?

$ go version
go version go1.17 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17"
GCCGO="gccgo"
AR="llvm-ar-11"
CC="clang-11"
CXX="clang++-11"
CGO_ENABLED="1"
GOMOD="/redacted/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3117786750=/tmp/go-build -gno-record-gcc-switches"

What did you do?

CGO_CFLAGS="-g3 -O2 -fsanitize=undefined,address -fno-omit-frame-pointer" \
CGO_LDFLAGS="-g3 -O2 -fsanitize=undefined,address -fno-omit-frame-pointer" \
go run -v github.com/FiloSottile/mkcert@v1.4.1 --help

What did you expect to see?

It run successfully.

What did you see instead?

The UBSan and ASan errors are expected, of course. But the crash is not.

os/user(.text): relocation target malloc not defined
os/user(.text): relocation target __ubsan_handle_type_mismatch_v1 not defined
os/user(.text): relocation target __asan_report_load_n not defined
os/user(.text): relocation target __asan_report_store_n not defined
os/user(.text): relocation target __asan_init not defined
os/user(.text): relocation target __asan_version_mismatch_check_v8 not defined
os/user(.text): relocation target free not defined
os/user(.text): relocation target __asan_report_load_n not defined
os/user(.text): relocation target __ubsan_handle_type_mismatch_v1 not defined
os/user(.text): relocation target getgrgid_r not defined
os/user(.text): relocation target __asan_report_store_n not defined
os/user(.text): relocation target __ubsan_handle_pointer_overflow not defined
os/user(.text): relocation target getgrnam_r not defined
os/user(.text): relocation target getpwnam_r not defined
os/user(.text): relocation target __ubsan_handle_nonnull_arg not defined
os/user(.text): relocation target getpwuid_r not defined
os/user(.text): relocation target realloc not defined
os/user(.text): relocation target __asan_init not defined
os/user(.text): relocation target __asan_version_mismatch_check_v8 not defined
runtime/cgo(.text): relocation target __asan_option_detect_stack_use_after_return not defined
runtime/cgo(.text): relocation target __asan_stack_malloc_1 not defined
/usr/local/go/pkg/tool/linux_amd64/link: too many errors
unexpected fault address 0x7fc500473000
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x1 addr=0x7fc500473000 pc=0x464e6e]

goroutine 36 [running]:
runtime.throw({0x66cc67, 0xc000513d78})
	/usr/local/go/src/runtime/panic.go:1198 +0x71 fp=0xc000513d00 sp=0xc000513cd0 pc=0x434271
runtime.sigpanic()
	/usr/local/go/src/runtime/signal_unix.go:742 +0x2f6 fp=0xc000513d50 sp=0xc000513d00 pc=0x44a696
runtime.memmove()
	/usr/local/go/src/runtime/memmove_amd64.s:383 +0x42e fp=0xc000513d58 sp=0xc000513d50 pc=0x464e6e
cmd/link/internal/ld.(*OutBuf).WriteSym(0xc000532070, 0xc000142300, 0x0)
	/usr/local/go/src/cmd/link/internal/ld/outbuf.go:300 +0x195 fp=0xc000513dd8 sp=0xc000513d58 pc=0x5ab635
cmd/link/internal/ld.writeBlock(0xc000152000, 0x4d4b5a, 0xc000142300, {0xc000b4cb48, 0x2c4, 0xc0000100f0}, 0x0, 0x0, {0xc0000182ad, 0x1, ...})
	/usr/local/go/src/cmd/link/internal/ld/data.go:994 +0x38c fp=0xc000513f08 sp=0xc000513dd8 pc=0x555dec
cmd/link/internal/ld.writeBlocks.func1(0x0, 0xc000124160, {0xc000b4cb48, 0x0, 0xc000038fd0}, 0x4d56cd, 0x0, {0xc0000182ad, 0x1, 0x1})
	/usr/local/go/src/cmd/link/internal/ld/data.go:951 +0x76 fp=0xc000513f80 sp=0xc000513f08 pc=0x5559d6
cmd/link/internal/ld.writeBlocks·dwrap·2()
	/usr/local/go/src/cmd/link/internal/ld/data.go:954 +0x63 fp=0xc000513fe0 sp=0xc000513f80 pc=0x555923
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc000513fe8 sp=0xc000513fe0 pc=0x463be1
created by cmd/link/internal/ld.writeBlocks
	/usr/local/go/src/cmd/link/internal/ld/data.go:950 +0x585

goroutine 1 [semacquire]:
sync.runtime_Semacquire(0xc000100e00)
	/usr/local/go/src/runtime/sema.go:56 +0x25
sync.(*WaitGroup).Wait(0xc00059c050)
	/usr/local/go/src/sync/waitgroup.go:130 +0x71
cmd/link/internal/ld.asmb(0xc000152000)
	/usr/local/go/src/cmd/link/internal/ld/asmb.go:62 +0x1c5
cmd/link/internal/ld.Main(_, {0x20, 0x20, 0x1, 0x7, 0x10, 0x0, {0x0, 0x0}, {0x678977, ...}, ...})
	/usr/local/go/src/cmd/link/internal/ld/main.go:343 +0x137f
main.main()
	/usr/local/go/src/cmd/link/main.go:69 +0x1005

goroutine 18 [semacquire]:
sync.runtime_Semacquire(0x0)
	/usr/local/go/src/runtime/sema.go:56 +0x25
sync.(*WaitGroup).Wait(0x634c00)
	/usr/local/go/src/sync/waitgroup.go:130 +0x71
cmd/link/internal/ld.writeBlocks(0xc000152000, 0xc0005a2a10, 0xc000150000, 0xc000142300, {0xc000b48000, 0xc2d, 0x1000}, 0x401000, 0x173570, {0xc0000182ad, ...})
	/usr/local/go/src/cmd/link/internal/ld/data.go:966 +0x5fa
cmd/link/internal/ld.CodeblkPad(...)
	/usr/local/go/src/cmd/link/internal/ld/data.go:876
cmd/link/internal/ld.asmb.func1(0x4, 0xc0010b0000, 0x1091, 0x1400)
	/usr/local/go/src/cmd/link/internal/ld/asmb.go:37 +0xa5
cmd/link/internal/ld.writeParallel.func1()
	/usr/local/go/src/cmd/link/internal/ld/data.go:1030 +0x70
created by cmd/link/internal/ld.writeParallel
	/usr/local/go/src/cmd/link/internal/ld/data.go:1028 +0x1a5

goroutine 113 [runnable]:
cmd/link/internal/ld.writeBlocks·dwrap·2()
	/usr/local/go/src/cmd/link/internal/ld/data.go:950
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:1581 +0x1
created by cmd/link/internal/ld.writeBlocks
	/usr/local/go/src/cmd/link/internal/ld/data.go:950 +0x585

goroutine 35 [runnable]:
syscall.Syscall(0x3, 0x3, 0x0, 0x0)
	/usr/local/go/src/syscall/asm_linux_amd64.s:20 +0x5
syscall.Close(0x685780)
	/usr/local/go/src/syscall/zsyscall_linux_amd64.go:286 +0x30
internal/poll.(*FD).destroy(0xc0000602a0)
	/usr/local/go/src/internal/poll/fd_unix.go:84 +0x51
internal/poll.(*FD).decref(0x0)
	/usr/local/go/src/internal/poll/fd_mutex.go:213 +0x54
internal/poll.(*FD).Close(0xc0000602a0)
	/usr/local/go/src/internal/poll/fd_unix.go:107 +0x4f
os.(*file).close(0xc0000602a0)
	/usr/local/go/src/os/file_unix.go:253 +0xad
os.(*File).Close(...)
	/usr/local/go/src/os/file_posix.go:26
cmd/link/internal/ld.(*OutBuf).Close(0xc00014e070)
	/usr/local/go/src/cmd/link/internal/ld/outbuf.go:127 +0xdd
cmd/link/internal/ld.linknew.func1()
	/usr/local/go/src/cmd/link/internal/ld/sym.go:63 +0x2e
cmd/link/internal/ld.runAtExitFuncs(...)
	/usr/local/go/src/cmd/link/internal/ld/util.go:23
cmd/link/internal/ld.Exit(0x6d24c0)
	/usr/local/go/src/cmd/link/internal/ld/util.go:30 +0x37
cmd/link/internal/ld.Exitf({0x671be0, 0x48}, {0x0, 0x0, 0x0})
	/usr/local/go/src/cmd/link/internal/ld/util.go:38 +0xce
cmd/link/internal/ld.afterErrorAction()
	/usr/local/go/src/cmd/link/internal/ld/util.go:49 +0x50
cmd/link/internal/loader.(*ErrorReporter).Errorf(0xc000152010, 0x20738, {0x67b386, 0x20}, {0xc00058caa8, 0x1, 0x1})
	/usr/local/go/src/cmd/link/internal/loader/loader.go:2641 +0x195
cmd/link/internal/ld.(*ErrorReporter).errorUnresolved(0xc000152010, 0xc000142300, 0x20738, 0x20745)
	/usr/local/go/src/cmd/link/internal/ld/errors.go:63 +0x3a6
cmd/link/internal/ld.(*relocSymState).relocsym(0xc00058ce98, 0x20738, {0x7fc500366740, 0x1e4, 0x3118c0})
	/usr/local/go/src/cmd/link/internal/ld/data.go:230 +0x2f10
cmd/link/internal/ld.writeBlock(0xc000152000, 0x0, 0xc000142300, {0xc000b48000, 0xc2d, 0x0}, 0x0, 0x0, {0xc0000182ad, 0x1, ...})
	/usr/local/go/src/cmd/link/internal/ld/data.go:995 +0x3ac
cmd/link/internal/ld.writeBlocks.func1(0xc001052000, 0x38e, {0xc000b48000, 0x900000000000000, 0x1b}, 0xc000f6f7b0, 0xc00015c480, {0xc0000182ad, 0x1, 0x1})
	/usr/local/go/src/cmd/link/internal/ld/data.go:951 +0x76
created by cmd/link/internal/ld.writeBlocks
	/usr/local/go/src/cmd/link/internal/ld/data.go:950 +0x585

goroutine 20 [runnable]:
cmd/link/internal/loader.(*Loader).OuterSym(...)
	/usr/local/go/src/cmd/link/internal/loader/loader.go:1748
cmd/link/internal/loader.(*Loader).AttrSubSymbol(...)
	/usr/local/go/src/cmd/link/internal/loader/loader.go:1172
cmd/link/internal/ld.writeBlocks(0xc000152000, 0xc0005a2af0, 0xc000150000, 0xc000142300, {0xc0005c2000, 0x340c, 0x340c}, 0x575000, 0x158170, {0x867280, ...})
	/usr/local/go/src/cmd/link/internal/ld/data.go:900 +0x676
cmd/link/internal/ld.writeDatblkToOutBuf(...)
	/usr/local/go/src/cmd/link/internal/ld/data.go:1048
cmd/link/internal/ld.datblk(0x0, 0x0, 0x0, 0x0)
	/usr/local/go/src/cmd/link/internal/ld/data.go:1036 +0x65
cmd/link/internal/ld.writeParallel.func1()
	/usr/local/go/src/cmd/link/internal/ld/data.go:1030 +0x70
created by cmd/link/internal/ld.writeParallel
	/usr/local/go/src/cmd/link/internal/ld/data.go:1028 +0x1a5

goroutine 21 [semacquire]:
sync.runtime_Semacquire(0x0)
	/usr/local/go/src/runtime/sema.go:56 +0x25
sync.(*WaitGroup).Wait(0x634c00)
	/usr/local/go/src/sync/waitgroup.go:130 +0x71
cmd/link/internal/ld.writeBlocks(0xc000152000, 0xc0005a2b60, 0xc000150000, 0xc000142300, {0xc0005c2000, 0x340c, 0x340c}, 0x6ce000, 0x45920, {0x867280, ...})
	/usr/local/go/src/cmd/link/internal/ld/data.go:966 +0x5fa
cmd/link/internal/ld.writeDatblkToOutBuf(...)
	/usr/local/go/src/cmd/link/internal/ld/data.go:1048
cmd/link/internal/ld.datblk(0x0, 0x0, 0x0, 0x0)
	/usr/local/go/src/cmd/link/internal/ld/data.go:1036 +0x65
cmd/link/internal/ld.writeParallel.func1()
	/usr/local/go/src/cmd/link/internal/ld/data.go:1030 +0x70
created by cmd/link/internal/ld.writeParallel
	/usr/local/go/src/cmd/link/internal/ld/data.go:1028 +0x1a5
@elagergren-spideroak elagergren-spideroak changed the title cmd/link: SIGSEGV cmd/link: SIGSEGV running "go run" Aug 19, 2021
@mknyszek mknyszek added this to the Go1.18 milestone Aug 19, 2021
@mknyszek
Copy link
Contributor

@mknyszek mknyszek commented Aug 19, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants