Linearizability tests for concurrent maps and sets#328
Conversation
a86a160 to
96903f7
Compare
|
This looks AWESOME!!! thanks for the contribution, I will have a look at it in the near future and integrate. |
|
@alefedor Can you please open "They also expose another bug that NonBlockingIdentityHashMap.replace fails if there were no such key before. |
|
I was curious and tried this test against ConcurrentHashMap, but it fails on JDK16. Any insights on why? |
|
Hi @ben-manes ! Nice observation, that's definitely a bug in Deducing from the fact that Lincheck can find this bug in the stress testing mode, but not in the model checking one, I suppose that it is related to weak memory model effects (e.g., missing memory barriers). |
|
Okay, it may also be a feature, not a bug |
|
Ahh, that helps explain it then because a backport of CHMv7 also fails in a similar fashion. I was curious about adding the checks to Caffeine which has an |
Yes, sure. Email: afedorov2602@gmail.com |
This pull request adds linearizability tests for concurrent maps and sets, based on Lincheck.
Lincheck tests are written in a declarative style, for which you need only to declare possible concurrent operations in the data structure - Lincheck will generate concurrent scenarios, run them, and verify their results automatically.
The tests help to reproduce the bug in #319 with a trace available for an incorrect execution.
They also expose another bug that
NonBlockingIdentityHashMap.replacefails if there were no such key before.For example,
new NonBlockingIdentityHashMap().replace(1, 0);will throw anAssertionError, because of unexpectednullvalue. I have a strong feeling that aTOMBSTONEshould have been there instead.I also found that a
sizemethod is not linearizable when a concurrentputoperation is in action. But I think that it is a feature rather than a bug, because efficient and linearizablesizeoperation is often difficult to implement, although I haven't found any note in the documentation about the problem.