Skip to content

libs: Simplify implementations of thread parking and guard::enable#234

Merged
RyanGlScott merged 1 commit intomasterfrom
T226-simplify-thread-parking-and-guard
Feb 2, 2026
Merged

libs: Simplify implementations of thread parking and guard::enable#234
RyanGlScott merged 1 commit intomasterfrom
T226-simplify-thread-parking-and-guard

Conversation

@RyanGlScott
Copy link
Contributor

Fixes #226.

@RyanGlScott RyanGlScott added the standard libraries Issues involving mir-json's modified versions of the Rust standard libraries label Jan 26, 2026
Comment on lines +247 to +248
* We use the `unsupported` configuration for thread parking, where all
parking-related functions are treated as no-ops.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC crux-mir has some limited support for verifying multithreaded programs. Is that now going to silently misbehave on programs that call park()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Truth be told, I don't have a whole lot of insight into the concurrency-related parts of crux-mir. (As I understand it, they consist of a handful of concurrency-related primitives, for which crux-mir provides overrides for here.)

FWIW, none of the test cases under crux-mir/test/concurrency, so I'm not even clear if park() is intended to be under the scope of crux-mir's concurrency support.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My worry is that where previously it would crash in an obvious way if your program calls park(), now it may silently produce unsound results. For example, if the concurrency support is meant to explore all possible interleavings, it will miss some interleavings because the unsupported version of park() doesn't include any operations that could trigger a context switch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. How should we proceed, then? Should we try implementing our own configuration of thread parking in terms of the concurrency-related primitives? If so, I'll likely need some guidance here, as I'm not at all familiar with this part of the code.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I was going to suggest implementing parking in terms of Mutex and Condvar, on the assumption that those are already calling the necessary Crucible concurrency hooks, but it turns out Condvar is also implemented as a bunch of no-ops. So probably the best path forward here is to stick with the no-op parker, and maybe document that the crux-mir concurrency support is currently broken/bitrotted. (Aside from Condvar, it looks like the various atomic types are also missing calls to concurrency hooks—see GaloisInc/crucible@b38fdfb.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right. I opened #238 a while back about this, so it would be good to cite that issue here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done this in d2a690b.

@RyanGlScott RyanGlScott force-pushed the T226-simplify-thread-parking-and-guard branch from d2a690b to 4916b63 Compare January 30, 2026 13:42
@RyanGlScott RyanGlScott force-pushed the T226-simplify-thread-parking-and-guard branch from 4916b63 to 302330a Compare February 2, 2026 18:33
@RyanGlScott RyanGlScott merged commit 886c15a into master Feb 2, 2026
5 checks passed
@RyanGlScott RyanGlScott deleted the T226-simplify-thread-parking-and-guard branch February 2, 2026 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

standard libraries Issues involving mir-json's modified versions of the Rust standard libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libs: Use Crucible-friendly implementations of Parker and guard::enable

3 participants