Skip to content

Instantly share code, notes, and snippets.

@rakyll rakyll/main.go
Last active Feb 9, 2017

What would you like to do?
$ go run main.go
fatal error: concurrent map writes
goroutine 34 [running]:
runtime.throw(0x89200, 0x15)
/Users/jbd/go/src/runtime/panic.go:530 +0x90 fp=0xc8200806d8 sp=0xc8200806c0
runtime.mapassign1(0x5e940, 0xc8200161e0, 0xc8200807a0, 0xc8200807a0)
/Users/jbd/go/src/runtime/hashmap.go:445 +0xb1 fp=0xc820080780 sp=0xc8200806d8
main.main.func1(0xc8200161e0, 0xc82000a170)
/Users/jbd/src/ +0x50 fp=0xc8200807b0 sp=0xc820080780
/Users/jbd/go/src/runtime/asm_amd64.s:1998 +0x1 fp=0xc8200807b8 sp=0xc8200807b0
created by main.main
/Users/jbd/src/ +0x9d
goroutine 1 [sleep]:
/Users/jbd/go/src/runtime/time.go:59 +0xf9
/Users/jbd/src/ +0xc1
exit status 2
package main
import "time"
const n = 50
func main() {
m := make(map[int]struct{}, n)
for i := 0; i < n; i++ {
go func() {
m[i] = struct{}{}

This comment has been minimized.

Copy link

commented Feb 9, 2017

how is the race condition caught if you're not passing the -race flag ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.