Skip to content

golang/io: io.Copy will return an error that contain unexpected fault address when passing io.MultiWriter on darwin #60378

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

Closed
zyxkad opened this issue May 24, 2023 · 2 comments

Comments

@zyxkad
Copy link
Contributor

zyxkad commented May 24, 2023

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

$ go version
go version go1.20.4 darwin/arm64

Does this issue reproduce with the latest release?

Yes, but can't reproduce on https://play.go.dev

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

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN="/Users/ckpn/Mine/projects/golang/bin"
GOCACHE="/Users/ckpn/Library/Caches/go-build"
GOENV="/Users/ckpn/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/ckpn/Mine/projects/golang/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/ckpn/Mine/projects/golang"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/Cellar/go/1.20.4/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.20.4/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20.4"
GCCGO="gccgo"
AR="ar"
CC="cc"
CXX="c++"
CGO_ENABLED="1"
GOMOD="/Users/ckpn/Mine/projects/golang/src/github.com/kmcsr/server-installer/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/3g/rxdhvbj96lv68y35t2cvghkr0000gn/T/go-build1530394242=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

https://go.dev/play/p/66mjQVcjM5X

What did you expect to see?

Program run well

What did you see instead?

unexpected fault address 0x568ea4b30018
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x2 addr=0x568ea4b30018 pc=0x102d59410]

goroutine 1 [running]:
runtime.throw({0x102ed5a84?, 0x102ed9a47?})
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/panic.go:1047 +0x40 fp=0x140001e97c0 sp=0x140001e9790 pc=0x102cce900
runtime.sigpanic()
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/signal_unix.go:851 +0x1a8 fp=0x140001e9800 sp=0x140001e97c0 pc=0x102ce51b8
fmt.(*pp).printArg(0x14000116270, {0x568ea4b30008?, 0xd63}, 0x76)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/fmt/print.go:707 +0x1d0 fp=0x140001e98b0 sp=0x140001e9810 pc=0x102d59410
fmt.(*pp).doPrintln(0x14000116270, {0x140001e9ab8?, 0x2, 0x0?})
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/fmt/print.go:1223 +0x3c fp=0x140001e9930 sp=0x140001e98b0 pc=0x102d5d31c
fmt.Fprintln({0x102fd0788, 0x1400000e018}, {0x140001e9ab8, 0x2, 0x2})
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/fmt/print.go:304 +0x44 fp=0x140001e9980 sp=0x140001e9930 pc=0x102d568b4
fmt.Println(...)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/fmt/print.go:314
github.com/kmcsr/server-installer.checkHashStream({0x12a6ad818, 0x14000150180}, 0x140003249f0, {0x102fd0788?, 0x1400000e1d0})
        /Users/ckpn/Mine/projects/golang/src/github.com/kmcsr/server-installer/utils.go:95 +0x5d0 fp=0x140001e9b60 sp=0x140001e9980 pc=0x102ed15e0
github.com/kmcsr/server-installer.downloadAnyAndCheckHashes({0x140000268c0, 0x1, 0x102ed602d?}, 0x6?, {0x14000393500, 0x24})
        /Users/ckpn/Mine/projects/golang/src/github.com/kmcsr/server-installer/utils.go:152 +0x310 fp=0x140001e9cc0 sp=0x140001e9b60 pc=0x102ed1ab0
github.com/kmcsr/server-installer.(*Mrpack).InstallServerWithOptional(0x1400031c240, {0x102f4ec60, 0x1}, 0x102fce7c0)
        /Users/ckpn/Mine/projects/golang/src/github.com/kmcsr/server-installer/mrpack.go:187 +0x480 fp=0x140001e9db0 sp=0x140001e9cc0 pc=0x102ecfd90
github.com/kmcsr/server-installer.(*Mrpack).InstallServer(...)
        /Users/ckpn/Mine/projects/golang/src/github.com/kmcsr/server-installer/mrpack.go:156
main.main()
        /Users/ckpn/Mine/projects/golang/src/github.com/kmcsr/server-installer/cli/main.go:90 +0x514 fp=0x140001e9f70 sp=0x140001e9db0 pc=0x102ed3d74
runtime.main()
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/proc.go:250 +0x248 fp=0x140001e9fd0 sp=0x140001e9f70 pc=0x102cd0f28
runtime.goexit()
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x140001e9fd0 sp=0x140001e9fd0 pc=0x102cffd54

goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/proc.go:381 +0xe4 fp=0x14000048fa0 sp=0x14000048f80 pc=0x102cd1354
runtime.goparkunlock(...)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/proc.go:387
runtime.forcegchelper()
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/proc.go:305 +0xb8 fp=0x14000048fd0 sp=0x14000048fa0 pc=0x102cd1198
runtime.goexit()
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000048fd0 sp=0x14000048fd0 pc=0x102cffd54
created by runtime.init.6
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/proc.go:293 +0x24

goroutine 17 [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/proc.go:381 +0xe4 fp=0x14000044760 sp=0x14000044740 pc=0x102cd1354
runtime.goparkunlock(...)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/proc.go:387
runtime.bgsweep(0x0?)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/mgcsweep.go:278 +0xa4 fp=0x140000447b0 sp=0x14000044760 pc=0x102cbe324
runtime.gcenable.func1()
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/mgc.go:178 +0x28 fp=0x140000447d0 sp=0x140000447b0 pc=0x102cb30d8
runtime.goexit()
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x140000447d0 sp=0x140000447d0 pc=0x102cffd54
created by runtime.gcenable
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/mgc.go:178 +0x74

goroutine 18 [GC scavenge wait]:
runtime.gopark(0x1400008c000?, 0x102f4ea58?, 0x1?, 0x0?, 0x0?)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/proc.go:381 +0xe4 fp=0x14000044f50 sp=0x14000044f30 pc=0x102cd1354
runtime.goparkunlock(...)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/proc.go:387
runtime.(*scavengerState).park(0x10317fac0)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/mgcscavenge.go:400 +0x5c fp=0x14000044f80 sp=0x14000044f50 pc=0x102cbc1ac
runtime.bgscavenge(0x0?)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/mgcscavenge.go:628 +0x44 fp=0x14000044fb0 sp=0x14000044f80 pc=0x102cbc724
runtime.gcenable.func2()
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/mgc.go:179 +0x28 fp=0x14000044fd0 sp=0x14000044fb0 pc=0x102cb3078
runtime.goexit()
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000044fd0 sp=0x14000044fd0 pc=0x102cffd54
created by runtime.gcenable
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/mgc.go:179 +0xb8

goroutine 3 [finalizer wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/proc.go:381 +0xe4 fp=0x14000049580 sp=0x14000049560 pc=0x102cd1354
runtime.runfinq()
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/mfinal.go:193 +0x10c fp=0x140000497d0 sp=0x14000049580 pc=0x102cb216c
runtime.goexit()
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x140000497d0 sp=0x140000497d0 pc=0x102cffd54
created by runtime.createfing
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/mfinal.go:163 +0x84

goroutine 12 [select]:
runtime.gopark(0x14000106f80?, 0x2?, 0xa0?, 0x21?, 0x14000106f24?)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/proc.go:381 +0xe4 fp=0x14000106db0 sp=0x14000106d90 pc=0x102cd1354
runtime.selectgo(0x14000106f80, 0x14000106f20, 0x14000026640?, 0x0, 0x140003ee180?, 0x1)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/select.go:327 +0x690 fp=0x14000106ed0 sp=0x14000106db0 pc=0x102ce1630
net/http.(*persistConn).writeLoop(0x1400015a000)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/net/http/transport.go:2410 +0x9c fp=0x14000106fb0 sp=0x14000106ed0 pc=0x102eabfec
net/http.(*Transport).dialConn.func6()
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/net/http/transport.go:1766 +0x28 fp=0x14000106fd0 sp=0x14000106fb0 pc=0x102ea8cf8
runtime.goexit()
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000106fd0 sp=0x14000106fd0 pc=0x102cffd54
created by net/http.(*Transport).dialConn
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/net/http/transport.go:1766 +0x1214

goroutine 22 [IO wait]:
runtime.gopark(0xffffffffffffffff?, 0xffffffffffffffff?, 0x23?, 0x0?, 0x102d348b0?)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/proc.go:381 +0xe4 fp=0x14000123580 sp=0x14000123560 pc=0x102cd1354
runtime.netpollblock(0x0?, 0x0?, 0x0?)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/netpoll.go:527 +0x158 fp=0x140001235c0 sp=0x14000123580 pc=0x102ccaa08
internal/poll.runtime_pollWait(0x12a6f1938, 0x72)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/netpoll.go:306 +0xa0 fp=0x140001235f0 sp=0x140001235c0 pc=0x102cfa0c0
internal/poll.(*pollDesc).wait(0x14000182100?, 0x140000c6000?, 0x0)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/internal/poll/fd_poll_runtime.go:84 +0x28 fp=0x14000123620 sp=0x140001235f0 pc=0x102d496f8
internal/poll.(*pollDesc).waitRead(...)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/internal/poll/fd_poll_runtime.go:89
internal/poll.(*FD).Read(0x14000182100, {0x140000c6000, 0xd80, 0xd80})
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/internal/poll/fd_unix.go:167 +0x200 fp=0x140001236c0 sp=0x14000123620 pc=0x102d4a400
net.(*netFD).Read(0x14000182100, {0x140000c6000?, 0x14000123878?, 0x102e396ac?})
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/net/fd_posix.go:55 +0x28 fp=0x14000123710 sp=0x140001236c0 pc=0x102e061e8
net.(*conn).Read(0x1400009a000, {0x140000c6000?, 0x10319bbe0?, 0x1?})
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/net/net.go:183 +0x34 fp=0x14000123760 sp=0x14000123710 pc=0x102e10174
net.(*TCPConn).Read(0x140001237d8?, {0x140000c6000?, 0x140003dd4a0?, 0x18?})
        <autogenerated>:1 +0x2c fp=0x14000123790 sp=0x14000123760 pc=0x102e1aa0c
crypto/tls.(*atLeastReader).Read(0x140003dd4a0, {0x140000c6000?, 0x140003dd4a0?, 0x0?})
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/crypto/tls/conn.go:788 +0x40 fp=0x140001237e0 sp=0x14000123790 pc=0x102e3ae90
bytes.(*Buffer).ReadFrom(0x1400009e290, {0x102fd0068, 0x140003dd4a0})
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/bytes/buffer.go:202 +0x90 fp=0x14000123840 sp=0x140001237e0 pc=0x102d6ba30
crypto/tls.(*Conn).readFromUntil(0x1400009e000, {0x12a66bfc8?, 0x1400009a000}, 0x102e7376c?)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/crypto/tls/conn.go:810 +0xd4 fp=0x14000123880 sp=0x14000123840 pc=0x102e3b084
crypto/tls.(*Conn).readRecordOrCCS(0x1400009e000, 0x0)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/crypto/tls/conn.go:617 +0xd8 fp=0x14000123bf0 sp=0x14000123880 pc=0x102e38ed8
crypto/tls.(*Conn).readRecord(...)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/crypto/tls/conn.go:583
crypto/tls.(*Conn).Read(0x1400009e000, {0x140000f7000, 0x1000, 0x102e86fe8?})
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/crypto/tls/conn.go:1316 +0x178 fp=0x14000123c60 sp=0x14000123bf0 pc=0x102e3de28
bufio.(*Reader).Read(0x140000f2540, {0x140000e44a0, 0x9, 0x102ca123c?})
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/bufio/bufio.go:237 +0x1e0 fp=0x14000123ca0 sp=0x14000123c60 pc=0x102d6dc10
io.ReadAtLeast({0x102fcff28, 0x140000f2540}, {0x140000e44a0, 0x9, 0x9}, 0x9)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/io/io.go:332 +0xa0 fp=0x14000123cf0 sp=0x14000123ca0 pc=0x102d2ca20
io.ReadFull(...)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/io/io.go:351
net/http.http2readFrameHeader({0x140000e44a0?, 0x9?, 0x14000123d98?}, {0x102fcff28?, 0x140000f2540?})
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/net/http/h2_bundle.go:1567 +0x58 fp=0x14000123d40 sp=0x14000123cf0 pc=0x102e80688
net/http.(*http2Framer).ReadFrame(0x140000e4460)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/net/http/h2_bundle.go:1831 +0x84 fp=0x14000123df0 sp=0x14000123d40 pc=0x102e80dc4
net/http.(*http2clientConnReadLoop).run(0x14000123f88)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/net/http/h2_bundle.go:9187 +0xfc fp=0x14000123f40 sp=0x14000123df0 pc=0x102e9120c
net/http.(*http2ClientConn).readLoop(0x1400009c180)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/net/http/h2_bundle.go:9082 +0x5c fp=0x14000123fb0 sp=0x14000123f40 pc=0x102e906cc
net/http.(*http2Transport).newClientConn.func1()
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/net/http/h2_bundle.go:7779 +0x28 fp=0x14000123fd0 sp=0x14000123fb0 pc=0x102e8a2a8
runtime.goexit()
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000123fd0 sp=0x14000123fd0 pc=0x102cffd54
created by net/http.(*http2Transport).newClientConn
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/net/http/h2_bundle.go:7779 +0xad0

goroutine 11 [select]:
runtime.gopark(0x14000102f58?, 0x4?, 0xe0?, 0x57?, 0x14000102d98?)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/proc.go:381 +0xe4 fp=0x14000102c00 sp=0x14000102be0 pc=0x102cd1354
runtime.selectgo(0x14000102f58, 0x14000102d90, 0x1400012c180?, 0x0, 0x1400004a501?, 0x1)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/select.go:327 +0x690 fp=0x14000102d20 sp=0x14000102c00 pc=0x102ce1630
net/http.(*persistConn).readLoop(0x1400015a000)
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/net/http/transport.go:2227 +0xbec fp=0x14000102fb0 sp=0x14000102d20 pc=0x102eab05c
net/http.(*Transport).dialConn.func5()
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/net/http/transport.go:1765 +0x28 fp=0x14000102fd0 sp=0x14000102fb0 pc=0x102ea8d58
runtime.goexit()
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000102fd0 sp=0x14000102fd0 pc=0x102cffd54
created by net/http.(*Transport).dialConn
        /opt/homebrew/Cellar/go/1.20.4/libexec/src/net/http/transport.go:1765 +0x11c8
exit status 2
@randall77
Copy link
Contributor

copy(writers, ([]io.Writer)((unsafe.Pointer)(&hashers)))

This is incorrect. You cannot copy a []hash.Hash to a []io.Writer. You will have to iterate and assign each element individually.

https://go.dev/doc/faq#convert_slice_with_same_underlying_type

If you fix that and still see problems, please reopen.

@zyxkad
Copy link
Contributor Author

zyxkad commented May 24, 2023

Yeah it works, thanks very much

@golang golang locked and limited conversation to collaborators May 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants