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

Possible race condition in SpinLock #2

Open
mgodave opened this issue Nov 28, 2011 · 0 comments
Open

Possible race condition in SpinLock #2

mgodave opened this issue Nov 28, 2011 · 0 comments

Comments

@mgodave
Copy link

mgodave commented Nov 28, 2011

I believe there is a possible race condition in the SpinLock class. The following serialization shows the issue:

count: 0, writer: true

R1 writer.get => true
W1 writer.set(false)
R1 writer.get => false
W2 writer.set(true)
W2 count.get => 0
W2 enters critical section
R1 count.incrementAndGet => 1
R1 enters critical section

It looks like it is possible for a reader and a writer to be in the critical section at the same time.

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

No branches or pull requests

2 participants