Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: avoid sharing GlobalValues between build instances
This happens with `tinygo test` for example when testing multiple packages at the same time. I found this because the compiler crashed in `make tinygo-test-fast`: fatal error: concurrent map writes fatal error: concurrent map read and map write goroutine 15 [running]: github.com/tinygo-org/tinygo/builder.Build({0x40002d0be0, 0xa}, {0x0, 0x0}, {0x4000398048, 0x14}, 0x40003b0000) /home/ayke/src/tinygo/tinygo/builder/build.go:131 +0x388 main.buildAndRun({0x40002d0be0, 0xa}, 0x40003b0000, {0x8bc178, 0x40003a4090}, {0x0, 0x0, 0x0}, {0x0, 0x0, ...}, ...) /home/ayke/src/tinygo/tinygo/main.go:856 +0x45c main.Test({0x40002d0be0, 0xa}, {0x8bc118, 0x40000b3a08}, {0x0?, 0x0?}, 0x40001e6000, {0x0, 0x0}) /home/ayke/src/tinygo/tinygo/main.go:270 +0x758 main.main.func3() /home/ayke/src/tinygo/tinygo/main.go:1718 +0xe4 created by main.main in goroutine 1 /home/ayke/src/tinygo/tinygo/main.go:1712 +0x34ec My solution is essentially to copy the map over instead of modifying it directly. I've also moved the code up a little, because I think that's a more sensible place (out of the way of the whole package compile logic).
- Loading branch information