Skip to content

Commit 1eef09a

Browse files
committed
Embedded WASI: fix InitializeWithCopy VWT type mismatch
Fixes Embedded Swift concurrency tests that crash with this stack trace: ``` Error: Trap: indirect call type mismatch, expected FunctionType(parameters: [WasmTypes.ValueType.i32, WasmTypes.ValueType.i32], results: []), got FunctionType(parameters: [W asmTypes.ValueType.i32, WasmTypes.ValueType.i32, WasmTypes.ValueType.i32], results: [WasmTypes.ValueType.i32]) 0: swift::AsyncTask::completeFuture(swift::AsyncContext*) 1: completeTaskAndRelease(swift::AsyncContext*, swift::SwiftError*) 2: completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*) 3: $exIeAgHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTRyt_Tg5TATQ0_ 4: $exIeAgHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTRyt_Tg5TQ0_ 5: $e1a4MainV4mainyyYaFZyyYacfU_TATQ0_ 6: $e1a4MainV4mainyyYaFZyyYacfU_TY1_ 7: swift_task_switch 8: $e1a4MainV4mainyyYaFZyyYacfU_TQ0_ 9: $e1a4testSiyYaFTY0_ 10: swift::runJobInEstablishedExecutorContext(swift::Job*) 11: swift_job_run 12: $es19CooperativeExecutorC8runUntilyySbyXEKF 13: $es19CooperativeExecutorCs07RunLoopB0ssACP3runyyKFTW 14: swift_task_asyncMainDrainQueueImpl 15: swift_task_asyncMainDrainQueue 16: main 17: __main_void 18: _start 19: unknown ```
1 parent d63bbb9 commit 1eef09a

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

include/swift/ABI/Task.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ struct ResultTypeInfo {
241241
#else
242242
size_t size = 0;
243243
size_t alignMask = 0;
244-
void (*initializeWithCopy)(OpaqueValue *result, OpaqueValue *src) = nullptr;
244+
OpaqueValue * (*initializeWithCopy)(OpaqueValue *result, OpaqueValue *src, void *type) = nullptr;
245245
void (*storeEnumTagSinglePayload)(OpaqueValue *v, unsigned whichCase,
246246
unsigned emptyCases) = nullptr;
247247
void (*destroy)(OpaqueValue *, void *) = nullptr;
@@ -256,7 +256,7 @@ struct ResultTypeInfo {
256256
return alignMask + 1;
257257
}
258258
void vw_initializeWithCopy(OpaqueValue *result, OpaqueValue *src) {
259-
initializeWithCopy(result, src);
259+
initializeWithCopy(result, src, nullptr);
260260
}
261261
void vw_storeEnumTagSinglePayload(OpaqueValue *v, unsigned whichCase,
262262
unsigned emptyCases) {

include/swift/ABI/TaskOptions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ class ResultTypeInfoTaskOptionRecord : public TaskOptionRecord {
215215
size_t size;
216216
size_t alignMask;
217217

218-
void (*__ptrauth_swift_value_witness_function_pointer(
218+
OpaqueValue *(*__ptrauth_swift_value_witness_function_pointer(
219219
SpecialPointerAuthDiscriminators::InitializeWithCopy)
220-
initializeWithCopy)(OpaqueValue *, OpaqueValue *);
220+
initializeWithCopy)(OpaqueValue *, OpaqueValue *, void *);
221221

222222
void (*__ptrauth_swift_value_witness_function_pointer(
223223
SpecialPointerAuthDiscriminators::StoreEnumTagSinglePayload)

test/embedded/concurrency-async-let.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -parse-as-library %s -c -o %t/a.o
3-
// RUN: %target-clang %t/a.o -o %t/a.out -L%swift_obj_root/lib/swift/embedded/%target-cpu-apple-macos -lswift_Concurrency -lswift_ConcurrencyDefaultExecutor -dead_strip
3+
// RUN: %target-clang %t/a.o -o %t/a.out -L%swift_obj_root/lib/swift/embedded/%module-target-triple %target-clang-resource-dir-opt -lswift_Concurrency %target-swift-default-executor-opt -dead_strip
44
// RUN: %target-run %t/a.out | %FileCheck %s
55

66
// REQUIRES: executable_test
77
// REQUIRES: swift_in_compiler
88
// REQUIRES: optimized_stdlib
9-
// REQUIRES: OS=macosx
9+
// REQUIRES: OS=macosx || OS=wasip1
1010
// REQUIRES: swift_feature_Embedded
1111

1212
import _Concurrency

0 commit comments

Comments
 (0)