Skip to content

Embedded: fix arguments mismatch in ResultTypeInfo #80862

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MaxDesiatov
Copy link
Contributor

@MaxDesiatov MaxDesiatov commented Apr 16, 2025

Mismatched number of arguments between a call (including indirect calls) and declarations traps on Wasm. destroy is declared with two arguments, but was called with one argument in embedded concurrency runtime. Second argument of destroy in VW seems unused, so let's pass nullptr as a workaround.

Mismatched number of arguments traps on Wasm. Second argument of `destroy` in VW seems unused, so let's pass `nullptr` as a workaround.
@MaxDesiatov MaxDesiatov added runtime The Swift Runtime concurrency runtime Feature: umbrella label for concurrency runtime features embedded Embedded Swift WebAssembly Platform: WebAssembly labels Apr 16, 2025
@@ -259,7 +259,7 @@ struct ResultTypeInfo {
storeEnumTagSinglePayload(v, whichCase, emptyCases);
}
void vw_destroy(OpaqueValue *v) {
destroy(v);
destroy(v, nullptr);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggestions for how to test this with lit would be appreciated. I reckon we need some mock SerialExecutor implementation and Task invocation in such test? I've reproduced it with JavaScriptKit's JavaScriptEventLoop: SerialExecutor in the first place with this code.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally I would love to see runtime tests covering this. Can we / do we have runtime tests running wasm?

Copy link
Member

Choose a reason for hiding this comment

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

@MaxDesiatov I think this issue could be reproduced with default cooperative executor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have an existing non-embedded test suite for WASI. The best course of action would be enable that for embedded where possible, WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, sounds good to me

@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

@kubamracek
Copy link
Contributor

This looks about right, but I think it would be good to also fix the other witness functions, which have the same problem; and also it looks to me that even the non-embedded-swift version of this code has the same problem?

@kateinoigakukun
Copy link
Member

and also it looks to me that even the non-embedded-swift version of this code has the same problem?

@kubamracek In non-embedded path, the call receiver, metadata, is passed at the end of vw_destroy, so the function is called with (v, metadata) correctly.

@kubamracek
Copy link
Contributor

and also it looks to me that even the non-embedded-swift version of this code has the same problem?

@kubamracek In non-embedded path, the call receiver, metadata, is passed at the end of vw_destroy, so the function is called with (v, metadata) correctly.

Can you link the code in question? This, https://github.com/swiftlang/swift/pull/80862/files#diff-a08b11d44e9648d1e8a3f8b0d21488f95f88f7b48e13ff29219d663e25633ee3R235 says the opposite.

@kateinoigakukun
Copy link
Member

@kubamracek I mean, the call is just a forwarding call generated here, and the underlying destroy function is called with args + this.

@al45tair
Copy link
Contributor

Linux build failed with

<unknown>:0: error: missing required module '_SwiftSyntaxCShims'

@al45tair
Copy link
Contributor

@swift-ci Please smoke test Linux platform

@MaxDesiatov MaxDesiatov removed the runtime The Swift Runtime label Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
concurrency runtime Feature: umbrella label for concurrency runtime features embedded Embedded Swift WebAssembly Platform: WebAssembly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants