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/race: Go 1.2 race detector and map of pointers => nil defererence, segfault #7766

gopherbot opened this issue Apr 12, 2014 · 4 comments


Copy link

by andres.erbsen:

This bug does not appear (at least with the same test code) on the development version
(go version devel +93ad232384f8 Fri Apr 11 10:11:21 2014 -0700 linux/amd64) and may
therefore be already fixed.

The combination of go 1.2, the race detector, a map of pointers and a function returning
two values somehow results in a nil dereference on linux/x86_64.

What does 'go version' print?
go version go1.2.1 linux/amd64

What steps reproduce the problem?
If possible, include a link to a program on

1. Compile with "-race"
2. Run it

What happened?

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x400c52]

goroutine 1 [running]:
runtime.panic(0x438400, 0x4aea68)
    /build/go/src/go-1.2.1/src/pkg/runtime/panic.c:266 +0xb6
    main.go:10 +0x52

What should have happened instead?

no output

Either uncommenting the seemingly nop read from the map or compiling without
"-race" makes the segfault not happen.
Copy link

Comment 1 by andres.erbsen:

The playground link seems to be dead:
package main
var f = func() (int, int) {
    return 0, 0
var m = map[int]*int{1: new(int)}
func main() {
    // _ = m[1]
    _, *m[1] = f()

Copy link

Comment 2:

This appears to be fixed at tip.
odessa(~/src) % go run -race rr.go
odessa(~/src) % go version
go version devel +8e553855d1a3 Thu Apr 10 21:46:00 2014 -0700 + darwin/amd64
As it is very unlikely that there will be a 1.2.2 release, I'm making this issue fixed
for Go 1.3

Labels changed: added release-go1.3, repo-main, racedetector.

Status changed to Fixed.

Copy link

Comment 3:

It looks similar to issue #7561 but appears to be a different issue.

Copy link

dvyukov commented Apr 13, 2014

Comment 4:

If it's different, why it's fixed on tip?
Do we need to add another test?

@rsc rsc added this to the Go1.3 milestone Apr 14, 2015
@rsc rsc removed the release-go1.3 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

No branches or pull requests

5 participants