PromiseTask.isCancelled performs an unsynchronized read
See original GitHub issueIn #9744 @njhill changed PromiseTask.isCancelled to:
But task
is just a plain field:
A race detector is noticing this unsynchronized read/write.
The write is occurring in clearTaskAfterCompletion()
, which does mention the potential for a write race, which does seem likely to be minor:
I’ve not spent too much time looking at it, but it is unclear to me why task == CANCELLED
is even checked in isCancelled()
; it seems like DefaultPromise.isCancelled()
should be enough. It sort of seems like the semantics of isCancelled()
are being changed to be more of a isDone()
. But I don’t think I understand the code enough to know how serious this race is.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
PromiseTask.isCancelled performs an unsynchronized read ...
Motivation: PromiseTask.isCancelled performs an unsynchronized read and so may trigger race-detectors. As this was just done for a small optimization which ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There used to be more failures in Netty, but many of them have been fixed. I did find a whitelist and it appears the only Netty race whitelisted is from io.netty.util.Recycler$WeakOrderQueue.transfer (not saying such a race still exists). But I do see a reasonable number of races ignored for the java standard library. That might be to just allow the tool to be used; stop new issues from being introduced and clean up preexisting issues over time.
In any case, if we don’t get much performance benefit it is probably best to remove the optimization. If we can show the benefit then we can try to get on the whitelist.
Here we go https://github.com/netty/netty/pull/10066