mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-23 12:34:32 +02:00
6803402: Race condition in AbstractQueuedSynchronizer
Read fields in reverse initialization order Reviewed-by: martin
This commit is contained in:
parent
ee5c2301ec
commit
ca6e1aecc3
2 changed files with 8 additions and 4 deletions
|
@ -1222,8 +1222,10 @@ public abstract class AbstractQueuedLongSynchronizer
|
|||
// The correctness of this depends on head being initialized
|
||||
// before tail and on head.next being accurate if the current
|
||||
// thread is first in queue.
|
||||
Node h, s;
|
||||
return (h = head) != tail &&
|
||||
Node t = tail; // Read fields in reverse initialization order
|
||||
Node h = head;
|
||||
Node s;
|
||||
return h != t &&
|
||||
((s = h.next) == null || s.thread != Thread.currentThread());
|
||||
}
|
||||
|
||||
|
|
|
@ -1445,8 +1445,10 @@ public abstract class AbstractQueuedSynchronizer
|
|||
// The correctness of this depends on head being initialized
|
||||
// before tail and on head.next being accurate if the current
|
||||
// thread is first in queue.
|
||||
Node h, s;
|
||||
return (h = head) != tail &&
|
||||
Node t = tail; // Read fields in reverse initialization order
|
||||
Node h = head;
|
||||
Node s;
|
||||
return h != t &&
|
||||
((s = h.next) == null || s.thread != Thread.currentThread());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue