Skip to content

Commit ae2a4cc

Browse files
Merge pull request swiftlang#36842 from aschwaighofer/fix_withCancellationHandler_arm64e_windows
Fix with cancellation handler arm64e windows
2 parents 37aa203 + 5b39635 commit ae2a4cc

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

stdlib/public/Concurrency/Task.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -865,9 +865,9 @@ swift_task_addCancellationHandlerImpl(
865865
void *context) {
866866
void *allocation =
867867
swift_task_alloc(sizeof(CancellationNotificationStatusRecord));
868-
auto *record =
869-
new (allocation) CancellationNotificationStatusRecord(
870-
handler, context);
868+
auto unsigned_handler = swift_auth_code(handler, 3848);
869+
auto *record = new (allocation)
870+
CancellationNotificationStatusRecord(unsigned_handler, context);
871871

872872
swift_task_addStatusRecord(record);
873873
return record;

test/Concurrency/Runtime/cancellation_handler.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44

55
// rdar://76038845
66
// UNSUPPORTED: use_os_stdlib
7+
// UNSUPPORTED: OS=windows-msvc
8+
9+
// for sleep
10+
#if canImport(Darwin)
11+
import Darwin
12+
#elseif canImport(Glibc)
13+
import Glibc
14+
#endif
715

816
class Canary {
917
deinit {
@@ -21,10 +29,22 @@ if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) {
2129
}
2230
}
2331
task.cancel()
32+
sleep(1)
33+
detach {
34+
await Task.withCancellationHandler {
35+
print("Task was cancelled!")
36+
}
37+
operation: {
38+
print("Running the operation...")
39+
}
40+
}
41+
sleep(10)
2442
} else {
2543
// Fake prints to satisfy FileCheck.
2644
print("Canary")
2745
print("canary died")
46+
print("Running the operation...")
2847
}
2948
// CHECK: Canary
3049
// CHECK-NEXT: canary died
50+
// CHECK-NEXT: Running the operation...

0 commit comments

Comments
 (0)