crucible-mir: tolerant parsing of Unsupported instance shims - #1840
Draft
AmeliaRose802 wants to merge 1 commit into
Draft
crucible-mir: tolerant parsing of Unsupported instance shims#1840AmeliaRose802 wants to merge 1 commit into
AmeliaRose802 wants to merge 1 commit into
Conversation
Adds a new IkUnsupported InstanceKind that the JSON parser accepts when mir-json emits "kind": "Unsupported" for shim types it does not yet model (ConstructCoroutineInClosureShim, FutureDropPollShim, AsyncDropGlueCtorShim, AsyncDropGlue, ThreadLocalShim, FnPtrAddrShim). Previously mir_load_module would fail to parse the entire linked-mir.json if ANY function in the module referenced one of these shims, even when the user only intended to verify other functions. After this change, modules containing Unsupported shims load successfully; the error is deferred to translation/call time if the shim is actually reached.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
mir-jsonemits{"kind": "Unsupported"}for six instance shim variants it does not yet model:ConstructCoroutineInClosureShimThreadLocalShimFutureDropPollShimFnPtrAddrShimAsyncDropGlueCtorShimAsyncDropGlueThese appear in the
intrinsicsarray of any compiled crate that exercises async Rust, thread-locals, or function-pointer-address taking — even when the user's verified function never touches those code paths.Today the crucible-mir JSON parser at
crucible-mir/src/Mir/JSON.hs:159fails the entiremir_load_modulecall with"unsupported instance: Just (Object [\"kind\" .= \"Unsupported\"])"the moment it encounters one of these. This blocks SAW from verifying ordinary Rust code that happens to be in a crate or transitive dependency containing async machinery.Fix
Add a new
IkUnsupported Textconstructor toInstanceKindand accept"kind": "Unsupported"in the JSON parser. The optionalshim_kindpayload carries the original mir-json shim name so any downstream consumer can produce a clear, actionable error if the shim is actually called during translation.This is a tolerant-parse change: the module loads, the verified function (which doesn't reach the shim) succeeds, and a clear error is deferred to translation time should anyone ever try to compile or invoke the
IkUnsupportedinstance.Diff
No behavior change for modules that don't contain
Unsupportedinstances. Existing tests undercrux-mir/test/conc_eval/are not affected.Companion PR
shim_kindfield to mir-json'sUnsupportedemissions so the deferred error message can name the specific shim. (This crucible-mir PR works fine without the mir-json companion — ifshim_kindis absent, it falls back to"unknown".)End-to-end validation
I ran this fix against the test in
intTests/test_mir_async_basic/(synchronous helper alongside async fn) plus a hand-crafted module containing an injectedUnsupportedentry, and confirmed:Unsupportedinstances load successfully (previously failed at parse time).mir_verifyon a function that doesn't reach the shim succeeds.kindstrings (e.g."GarbageKind") still produce the original"unsupported instance: …"error — the fix is scoped to"Unsupported"only.Filed as draft for upstream review.