Skip to content

Fix "sync: inconsistent mutex state" panic #737

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

Merged
merged 3 commits into from
Jan 18, 2018

Conversation

canning-duck
Copy link
Contributor

  • Fix the panic by preventing undue acquisition of the semaphore.
  • Implement the lifo parameter in runtime_SemacquireMutex (not strictly required but improve the mutex fairness).

TestMutexFairness is now passing. Tested with Go 1.9 (gopherjs test -v sync).

#736

Copy link
Member

@dmitshur dmitshur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this fix @canning-duck.

I've tested your changes on the Go 1.10 branch and they work well. It fixes TestMutexFairness and the test program you posted in #736.

It's passing all tests on Go 1.9 too (via CI).

LGTM.

@@ -5,22 +5,32 @@ package sync
import "github.com/gopherjs/gopherjs/js"

var semWaiters = make(map[*uint32][]chan bool)
var semAwoken = make(map[*uint32]uint32)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to document what this map tracks.

@dmitshur dmitshur merged commit 9b73d05 into gopherjs:master Jan 18, 2018
@dmitshur
Copy link
Member

Thank you again @canning-duck for investigating and fixing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants