Tests: Reproducer for Swift 6.3 typed-throws async closure miscompile#12
Draft
krodak wants to merge 1 commit into
Draft
Tests: Reproducer for Swift 6.3 typed-throws async closure miscompile#12krodak wants to merge 1 commit into
krodak wants to merge 1 commit into
Conversation
dad4c01 to
746c781
Compare
24e91ea to
c98c67f
Compare
746c781 to
09bb61c
Compare
c98c67f to
351fd63
Compare
09bb61c to
30a9c43
Compare
351fd63 to
a52271a
Compare
30a9c43 to
aa02b44
Compare
a52271a to
a628444
Compare
aa02b44 to
982e9fb
Compare
a628444 to
1e50386
Compare
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.
Overview
A standalone, runnable reproducer for the Swift compiler bug that blocks the Swift-to-JS
async throwsreject path in the closures work (the "Known limitation" in the feature PR). This branch is stacked on top of that feature branch so reviewers see only the reproducer test in the diff.Root cause identified: this is swiftlang/swift#89320 ("Crash with typed/untyped throwing
asyncfunctions on Wasm"), with a fix in progress in swiftlang/swift#89715 (IRGen: fix async typed throws miscompiles on Wasm). On wasm32, IRGen places the indirect typed-error pointer afterswiftselfat thick call sites, but a captureless closure or function reference goes throughthin_to_thick_functionwhose thin signature has noswiftself; LLVM's wasm swiftcc padding appends the missing parameters, producing equal-arity but permuted signatures. The callee writes the thrown error through the caller's nullswiftself, and the caller reads a never-written slot.The bug triggers only when both conditions hold:
JSExceptionis ~36 bytes), andthin_to_thick_function(a captureless closure literal or a function reference).Tests/BridgeJSRuntimeTests/TypedThrowsAsyncClosureBugTests.swiftdemonstrates both conditions with labelled[REPRO]output. The suite stays green: the buggy cases are encoded as current-behaviour assertions with a comment to flip once swiftlang/swift#89715 lands (XCTExpectFailureis not available in the wasm XCTest runtime).What it shows
JSExceptionfrom captureless async closureJSExceptionfrom async functionJSExceptionfrom capturing async closureJSExceptionfrom untyped async closureTwo additional observations that raise severity beyond the trap documented in swiftlang/swift#89320:
Stringfield trapped withUnsafeBufferPointer has a nil start and nonzero countduring interpolation, and releasing corrupted references crashes inswift_release.Relationship to existing Swift issues
swiftselfso thin and thick signatures agree).Result.init(catching:)async trap on wasm, same root cause, used as a regression guard by the fix.Purpose
Internal review artifact to confirm the characterization before coordinating with the maintainers on the preferred path (merge with the documented limitation, box
JSExceptionstorage to fit the direct error convention, or wait for swiftlang/swift#89715). Run withmake unittest.