-
Notifications
You must be signed in to change notification settings - Fork 114
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
Avoid concurrency errors when combining /randomizeVcIterations
and /trackVerificationCoverage
#849
Conversation
Normally, Boogie generates only one task per split, so per-split data structures won’t be accessed concurrently. However, when using /randomizeVcIterations together with /trackVerificationCoverage, multiple tasks may concurrently update the `CoveredElements` property. This change will result in tracking the union of covered elements across all VC generation iterations, but that seems like reasonable behavior for a very rare use case.
Shouldn't we make it so that only one task does those updates? |
Then we either lose the performance benefit of running all iterations in parallel, or have complex logic for deciding which task does it, which could easily lead to a different concurrency bug. |
Wouldn't it be safer, and more performant, to create separate |
The only other fields that seem to be updated in the process are It would arguably be safer to do each iteration on a different |
/randomizeVcIterations
and /trackVerificationCoverage
Doing this turns out to be more complex than I'd thought. I'm inclined to merge the simpler change to a |
What's complex about it? I think it would be nice if a split can assume it's state doesn't get modified concurrently. In particular, making some of the state thread-safe and the rest not, seems like it would be laying a trap for future developers. |
Btw, does this line not also introduce suffer from not being thread-safe? boogie/Source/VCGeneration/Checker.cs Line 161 in baf6dbc
|
A fix is to update |
Only that the first thing I tried led to a deadlock that I couldn't reproduce locally but that consistently showed up in one of the CI jobs. I'm sure it's resolvable, it'll just take more time than I originally thought.
I do think that's the better approach. |
I think updating here to check for multiple instances of the pattern it's currently looking for should catch the problem. I can confirm that the updated test fails for me right now.
Yeah, I agree. And the refactoring you've recently done should make this more straightforward than it would have been in the past. |
This issue has a better solution now, so I'm going to close this PR. |
Normally, Boogie generates only one task per split, so per-split data structures won’t be accessed concurrently. However, when using /randomizeVcIterations together with /trackVerificationCoverage, multiple tasks may concurrently update the
CoveredElements
property. This PR makes the set of covered elements be aConcurrentBag
to allow updates.I think a more significant refactoring of this code makes sense, but is not as straightforward as it initially seemed. For the moment, this simple change allows a rarely but occasionally useful mode of operation to succeed with correct results and without crashing, so it's strictly better than what's there at the moment.