critical-section icon indicating copy to clipboard operation
critical-section copied to clipboard

Add `loom` support to `std` critical section implementation

Open datdenkikniet opened this issue 1 year ago • 0 comments

loom is a tool that can be used to validate concurrent programs exhaustively.

This PR adds support for loom to the std implementation of critical-section, with the loom-suggested approach of using a cfg for it. It raises the MSRV of this project to 1.73 when --cfg loom is specified, but otherwise does not affect it.

An example use-case for finding problems using loom can be found here. It uses the same critical section implementation as is provided here. Without it, loom assumes that there are no synchronization/interruption points when a critical section starts or ends. With loom, it runs all the concurrent permutations, and allowed us to repro (though we should've been using loom preventatively) a concurrency bug.

datdenkikniet avatar Mar 10 '25 12:03 datdenkikniet