Skip to content

Commit 29d95ce

Browse files
committed
[Concurrency] Fix ptrauth value for __ptrauth_swift_escalation_notification_function
Previously these records were not used at all, so changing this has no impact on existing runtimes. Note that we changedd the FunctionType because the previous one was slightly incorrect -- the context comes LAST in the type, not first.
1 parent 67e6373 commit 29d95ce

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

include/swift/ABI/MetadataValues.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1678,7 +1678,7 @@ namespace SpecialPointerAuthDiscriminators {
16781678
const uint16_t AsyncContextResume = 0xd707; // = 55047
16791679
const uint16_t AsyncContextYield = 0xe207; // = 57863
16801680
const uint16_t CancellationNotificationFunction = 0x1933; // = 6451
1681-
const uint16_t EscalationNotificationFunction = 0x5be4; // = 23524
1681+
const uint16_t EscalationNotificationFunction = 0xf59d; // = 62877
16821682
const uint16_t AsyncThinNullaryFunction = 0x0f08; // = 3848
16831683
const uint16_t AsyncFutureFunction = 0x720f; // = 29199
16841684

stdlib/public/Concurrency/Task.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1773,7 +1773,7 @@ swift_task_addPriorityEscalationHandlerImpl(
17731773
void *context) {
17741774
void *allocation =
17751775
swift_task_alloc(sizeof(EscalationNotificationStatusRecord));
1776-
auto unsigned_handler = swift_auth_code(handler, 3848); // FIXME: fix this number for ptrauth
1776+
auto unsigned_handler = swift_auth_code(handler, 62877);
17771777
auto *record = ::new (allocation)
17781778
EscalationNotificationStatusRecord(handler, context);
17791779

stdlib/public/Concurrency/Task.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -994,26 +994,12 @@ public func withTaskPriorityEscalationHandler<T, E>(
994994
let handler0: (UInt8) -> Void = {
995995
handler(TaskPriority(rawValue: $0))
996996
}
997-
let record = _taskaddPriorityEscalationHandler(handler: handler0)
998-
defer { _taskremovePriorityEscalationHandler(record: record) }
997+
let record = _taskAddPriorityEscalationHandler(handler: handler0)
998+
defer { _taskRemovePriorityEscalationHandler(record: record) }
999999

10001000
return try await operation()
10011001
}
10021002

1003-
@usableFromInline
1004-
@available(SwiftStdlib 9999, *)
1005-
@_silgen_name("swift_task_addPriorityEscalationHandler")
1006-
func _taskaddPriorityEscalationHandler(
1007-
handler: (UInt8) -> Void
1008-
) -> UnsafeRawPointer /*EscalationNotificationStatusRecord*/
1009-
1010-
@usableFromInline
1011-
@available(SwiftStdlib 9999, *)
1012-
@_silgen_name("swift_task_removePriorityEscalationHandler")
1013-
func _taskremovePriorityEscalationHandler(
1014-
record: UnsafeRawPointer /*EscalationNotificationStatusRecord*/
1015-
)
1016-
10171003
// ==== UnsafeCurrentTask ------------------------------------------------------
10181004

10191005
/// Calls a closure with an unsafe reference to the current task.
@@ -1185,6 +1171,20 @@ func _enqueueJobGlobalWithDeadline(_ seconds: Int64, _ nanoseconds: Int64,
11851171
_ toleranceSec: Int64, _ toleranceNSec: Int64,
11861172
_ clock: Int32, _ task: Builtin.Job)
11871173

1174+
@usableFromInline
1175+
@available(SwiftStdlib 9999, *)
1176+
@_silgen_name("swift_task_addPriorityEscalationHandler")
1177+
func _taskAddPriorityEscalationHandler(
1178+
handler: (UInt8) -> Void
1179+
) -> UnsafeRawPointer /*EscalationNotificationStatusRecord*/
1180+
1181+
@usableFromInline
1182+
@available(SwiftStdlib 9999, *)
1183+
@_silgen_name("swift_task_removePriorityEscalationHandler")
1184+
func _taskRemovePriorityEscalationHandler(
1185+
record: UnsafeRawPointer /*EscalationNotificationStatusRecord*/
1186+
)
1187+
11881188
@available(SwiftStdlib 5.1, *)
11891189
@usableFromInline
11901190
@_silgen_name("swift_task_asyncMainDrainQueue")

test/Concurrency/async_task_escalate_priority.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// UNSUPPORTED: DARWIN_SIMULATOR=ios
2020
// UNSUPPORTED: DARWIN_SIMULATOR=tvos
2121

22-
// rdar://107390341 - Temporarily disable for arm64e
22+
// rdar://107390341 - Because task escalation tests seem disabled on this platform
2323
// UNSUPPORTED: CPU=arm64e
2424

2525
import Darwin

0 commit comments

Comments
 (0)