Closed
Description
Hello,
We have some piece of code with a few goroutines and mutexes. Given a "certain" number of concurrent operations, the runtime panics with "sync: inconsistent mutex state" in GopherJS 1.9 (this one: https://golang.org/src/sync/mutex.go#L143). The issue does not occur with GopherJS 1.8, or on any other platform with Go 1.9 (android/ios/macos).
Regarding the Go and GopherJS source code, and as far as I understand it (ie. not very much), it seems that:
- Go 1.9 implements a new "mutex fairness" behavior (https://golang.org/src/sync/mutex.go#L42) that relies on the new parameters
lifo
andhandoff
ofruntime_SemacquireMutex
andruntime_Semrelease
respectively (https://golang.org/src/sync/runtime.go). - GopherJS 1.9 does not take theses parameters into account (https://github.com/gopherjs/gopherjs/blob/master/compiler/natives/src/sync/sync.go).
I'm not yet at ease isolating the issue in a unit-test but I'm ready to try patching our local copy of GopherJS and see how it goes. If I get it right, lifo
is about adding ch
at the head of semWaiters
instead of the tail. But what about handoff
? Has anyone any clue?