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

runtime: write of Go pointer 0xc0000b2330 to non-Go memory 0x7f0f9772f080 #28458

Closed
dominikh opened this issue Oct 29, 2018 · 2 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@dominikh
Copy link
Member

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

go version devel +3f3142ad99 Mon Oct 29 09:54:51 2018 +0000 linux/amd64

Does this issue reproduce with the latest release?

Does not reproduce with Go 1.11.1

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/dominikh/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/dominikh/prj/"
GOPROXY=""
GORACE=""
GOROOT="/home/dominikh/go"
GOTMPDIR=""
GOTOOLDIR="/home/dominikh/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build458020681=/tmp/go-build -gno-record-gcc-switches"

What did you do?

$ cat bar.go                     
package pkg

$ GOGC=1 GODEBUG=cgocheck=2 ~/go/bin/go build bar.go

What did you expect to see?

A successful build

What did you see instead?

$ GOGC=1 GODEBUG=cgocheck=2 ~/go/bin/go build bar.go
write of Go pointer 0xc0000b2330 to non-Go memory 0x7f0f9772f080
fatal error: Go pointer stored into non-Go memory

runtime stack:
runtime.throw(0x984ba7, 0x24)
	/home/dominikh/go/src/runtime/panic.go:608 +0x72
runtime.cgoCheckWriteBarrier.func1()
	/home/dominikh/go/src/runtime/cgocheck.go:48 +0xa9
runtime.systemstack(0xc000001200)
	/home/dominikh/go/src/runtime/asm_amd64.s:351 +0x66
runtime.mstart()
	/home/dominikh/go/src/runtime/proc.go:1154

goroutine 3 [running]:
runtime.systemstack_switch()
	/home/dominikh/go/src/runtime/asm_amd64.s:311 fp=0xc000059538 sp=0xc000059530 pc=0x455c50
runtime.cgoCheckWriteBarrier(0x7f0f9772f080, 0xc0000b2330)
	/home/dominikh/go/src/runtime/cgocheck.go:46 +0xb0 fp=0xc000059570 sp=0xc000059538 pc=0x405e40
runtime.wbBufFlush(0x7f0f9772f080, 0xc0000b2330)
	/home/dominikh/go/src/runtime/mwbbuf.go:189 +0x64 fp=0xc000059590 sp=0xc000059570 pc=0x4281c4
runtime.gcWriteBarrier(0xd86c70, 0xc000059628, 0x453c30, 0xd70440, 0xc000059670, 0x4263a6, 0xc0000b2330, 0x9b24d8, 0x10, 0x9467e0, ...)
	/home/dominikh/go/src/runtime/asm_amd64.s:1427 +0xb4 fp=0xc000059618 sp=0xc000059590 pc=0x457df4
runtime.queuefinalizer(0xc0000b2330, 0x9b24d8, 0x10, 0x9467e0, 0x9467e0)
	/home/dominikh/go/src/runtime/mfinal.go:121 +0x200 fp=0xc000059648 sp=0xc000059618 pc=0x418f50
runtime.freespecial(0x7f0f9d9cc180, 0xc0000b2330, 0x30)
	/home/dominikh/go/src/runtime/mheap.go:1383 +0xd6 fp=0xc000059680 sp=0xc000059648 pc=0x4263a6
runtime.(*mspan).sweep(0x7f0fa1e3f988, 0xc000059700, 0x42dc00)
	/home/dominikh/go/src/runtime/mgcsweep.go:256 +0x1d0 fp=0xc000059748 sp=0xc000059680 pc=0x422180
runtime.sweepone(0x0)
	/home/dominikh/go/src/runtime/mgcsweep.go:118 +0x26e fp=0xc0000597b0 sp=0xc000059748 pc=0x421d5e
runtime.bgsweep(0xc00002c070)
	/home/dominikh/go/src/runtime/mgcsweep.go:55 +0xa1 fp=0xc0000597d8 sp=0xc0000597b0 pc=0x421a61
runtime.goexit()
	/home/dominikh/go/src/runtime/asm_amd64.s:1340 +0x1 fp=0xc0000597e0 sp=0xc0000597d8 pc=0x457d31
created by runtime.gcenable
	/home/dominikh/go/src/runtime/mgc.go:208 +0x58

goroutine 1 [semacquire]:
sync.runtime_Semacquire(0xc000272d38)
	/home/dominikh/go/src/runtime/sema.go:56 +0x39
sync.(*WaitGroup).Wait(0xc000272d30)
	/home/dominikh/go/src/sync/waitgroup.go:130 +0x64
cmd/go/internal/work.(*Builder).Do(0xc0001f7720, 0xc00023e780)
	/home/dominikh/go/src/cmd/go/internal/work/exec.go:174 +0x389
cmd/go/internal/work.runBuild(0xd60140, 0xc0000a4170, 0x1, 0x1)
	/home/dominikh/go/src/cmd/go/internal/work/build.go:341 +0x37a
main.main()
	/home/dominikh/go/src/cmd/go/main.go:219 +0x83c

goroutine 19 [syscall]:
os/signal.signal_recv(0x0)
	/home/dominikh/go/src/runtime/sigqueue.go:139 +0x9c
os/signal.loop()
	/home/dominikh/go/src/os/signal/signal_unix.go:23 +0x22
created by os/signal.init.0
	/home/dominikh/go/src/os/signal/signal_unix.go:29 +0x41

goroutine 21 [select]:
cmd/go/internal/work.(*Builder).Do.func2(0xc000272d30, 0xc0001f7720, 0xc0001e35c0)
	/home/dominikh/go/src/cmd/go/internal/work/exec.go:155 +0x12f
created by cmd/go/internal/work.(*Builder).Do
	/home/dominikh/go/src/cmd/go/internal/work/exec.go:152 +0x365

goroutine 22 [select]:
cmd/go/internal/work.(*Builder).Do.func2(0xc000272d30, 0xc0001f7720, 0xc0001e35c0)
	/home/dominikh/go/src/cmd/go/internal/work/exec.go:155 +0x12f
created by cmd/go/internal/work.(*Builder).Do
	/home/dominikh/go/src/cmd/go/internal/work/exec.go:152 +0x365

goroutine 23 [syscall]:
syscall.Syscall(0x3, 0x5, 0x0, 0x0, 0x4b9545, 0xc00011c660, 0xc00020a0b0)
	/home/dominikh/go/src/syscall/asm_linux_amd64.s:18 +0x5
syscall.Close(0x5, 0x0, 0x0)
	/home/dominikh/go/src/syscall/zsyscall_linux_amd64.go:310 +0x40
internal/poll.(*FD).destroy(0xc00011c660, 0x4c3501, 0x0)
	/home/dominikh/go/src/internal/poll/fd_unix.go:78 +0x4e
internal/poll.(*FD).decref(0xc00011c660, 0x1, 0x0)
	/home/dominikh/go/src/internal/poll/fd_mutex.go:213 +0x42
internal/poll.(*FD).Close(0xc00011c660, 0x0, 0xb0)
	/home/dominikh/go/src/internal/poll/fd_unix.go:100 +0x95
os.(*file).close(0xc00011c660, 0x0, 0x0)
	/home/dominikh/go/src/os/file_unix.go:234 +0x38
os.(*File).Close(0xc000122008, 0xc00020a0b0, 0xaf)
	/home/dominikh/go/src/os/file_unix.go:226 +0x33
io/ioutil.WriteFile(0xc00021c000, 0x64, 0xc00020a0b0, 0xaf, 0xb0, 0x1b6, 0x1, 0xc00021c000)
	/home/dominikh/go/src/io/ioutil/ioutil.go:88 +0xc0
cmd/go/internal/cache.(*Cache).putIndexEntry(0xc0001e35a0, 0xdb25e84f1d32b965, 0x34b9c467b802f3a2, 0x8c534bbb7aa3ff7, 0x5a574f11c206f335, 0x141cfc9842c4b0e3, 0x24b96f99c8f4fb9a, 0x4c939b64e441ae27, 0x55b852781b9995a4, 0x0, ...)
	/home/dominikh/go/src/cmd/go/internal/cache/cache.go:340 +0x305
cmd/go/internal/cache.(*Cache).put(0xc0001e35a0, 0xdb25e84f1d32b965, 0x34b9c467b802f3a2, 0x8c534bbb7aa3ff7, 0x5a574f11c206f335, 0xa25e60, 0xc0000a4ed0, 0x457d01, 0x0, 0x0, ...)
	/home/dominikh/go/src/cmd/go/internal/cache/cache.go:383 +0x2cf
cmd/go/internal/cache.(*Cache).Put(0xc0001e35a0, 0xdb25e84f1d32b965, 0x34b9c467b802f3a2, 0x8c534bbb7aa3ff7, 0x5a574f11c206f335, 0xa25e60, 0xc0000a4ed0, 0x0, 0x0, 0x0, ...)
	/home/dominikh/go/src/cmd/go/internal/cache/cache.go:353 +0x8c
cmd/go/internal/cache.(*Cache).PutBytes(0xc0001e35a0, 0xdb25e84f1d32b965, 0x34b9c467b802f3a2, 0x8c534bbb7aa3ff7, 0x5a574f11c206f335, 0xd86d10, 0x0, 0x0, 0x8c534bbb7aa3ff7, 0x5a574f11c206f335)
	/home/dominikh/go/src/cmd/go/internal/cache/cache.go:388 +0xae
cmd/go/internal/work.(*Builder).updateBuildID(0xc0001f7720, 0xc00023e8c0, 0xc0000b2090, 0x23, 0x1, 0x0, 0x0)
	/home/dominikh/go/src/cmd/go/internal/work/buildid.go:616 +0xb72
cmd/go/internal/work.(*Builder).build(0xc0001f7720, 0xc00023e8c0, 0x0, 0x0)
	/home/dominikh/go/src/cmd/go/internal/work/exec.go:737 +0x18e9
cmd/go/internal/work.(*Builder).Do.func1(0xc00023e8c0)
	/home/dominikh/go/src/cmd/go/internal/work/exec.go:107 +0x6c
cmd/go/internal/work.(*Builder).Do.func2(0xc000272d30, 0xc0001f7720, 0xc0001e35c0)
	/home/dominikh/go/src/cmd/go/internal/work/exec.go:165 +0xbb
created by cmd/go/internal/work.(*Builder).Do
	/home/dominikh/go/src/cmd/go/internal/work/exec.go:152 +0x365

goroutine 24 [select]:
cmd/go/internal/work.(*Builder).Do.func2(0xc000272d30, 0xc0001f7720, 0xc0001e35c0)
	/home/dominikh/go/src/cmd/go/internal/work/exec.go:155 +0x12f
created by cmd/go/internal/work.(*Builder).Do
	/home/dominikh/go/src/cmd/go/internal/work/exec.go:152 +0x365

goroutine 25 [select]:
cmd/go/internal/work.(*Builder).Do.func2(0xc000272d30, 0xc0001f7720, 0xc0001e35c0)
	/home/dominikh/go/src/cmd/go/internal/work/exec.go:155 +0x12f
created by cmd/go/internal/work.(*Builder).Do
	/home/dominikh/go/src/cmd/go/internal/work/exec.go:152 +0x365

goroutine 26 [select]:
cmd/go/internal/work.(*Builder).Do.func2(0xc000272d30, 0xc0001f7720, 0xc0001e35c0)
	/home/dominikh/go/src/cmd/go/internal/work/exec.go:155 +0x12f
created by cmd/go/internal/work.(*Builder).Do
	/home/dominikh/go/src/cmd/go/internal/work/exec.go:152 +0x365

goroutine 27 [select]:
cmd/go/internal/work.(*Builder).Do.func2(0xc000272d30, 0xc0001f7720, 0xc0001e35c0)
	/home/dominikh/go/src/cmd/go/internal/work/exec.go:155 +0x12f
created by cmd/go/internal/work.(*Builder).Do
	/home/dominikh/go/src/cmd/go/internal/work/exec.go:152 +0x365

goroutine 28 [select]:
cmd/go/internal/work.(*Builder).Do.func2(0xc000272d30, 0xc0001f7720, 0xc0001e35c0)
	/home/dominikh/go/src/cmd/go/internal/work/exec.go:155 +0x12f
created by cmd/go/internal/work.(*Builder).Do
	/home/dominikh/go/src/cmd/go/internal/work/exec.go:152 +0x365
@dominikh dominikh added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 29, 2018
@dominikh dominikh added this to the Go1.12 milestone Oct 29, 2018
@randall77
Copy link
Contributor

This is writing the argument to a finalizer to the finalizer queue entry.
(In mfinal.go, f.arg = p).
We should be allowed to do this write. The finalizer queue entry is allocated by persistentalloc. Maybe we just need to avoid the write barrier here, as we manage the target memory explicitly.

@aclements

This code has been this way for a while. I'm not convinced 1.11 is free from this bug - it would be pretty hard to trigger.

@bcmills bcmills changed the title cmd/go: write of Go pointer 0xc0000b2330 to non-Go memory 0x7f0f9772f080 runtime: write of Go pointer 0xc0000b2330 to non-Go memory 0x7f0f9772f080 Oct 29, 2018
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/155697 mentions this issue: runtime: skip writes to persistent memory in cgo checker

changkun added a commit to golang-design/under-the-hood that referenced this issue Jan 27, 2019
@golang golang locked and limited conversation to collaborators Jan 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants