Skip to content

Commit 6345c4b

Browse files
committed
[stdlib] Make expected actor isolation checking crash by default
Only affects projects compiled with `-enable-actor-data-race-checks` flag.
1 parent b98d7a5 commit 6345c4b

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

stdlib/public/Concurrency/Actor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ static bool swift_task_isCurrentExecutorImpl(SerialExecutorRef executor) {
353353
/// 0 - no logging
354354
/// 1 - warn on each instance
355355
/// 2 - fatal error
356-
static unsigned unexpectedExecutorLogLevel = 1;
356+
static unsigned unexpectedExecutorLogLevel = 2;
357357

358358
static void checkUnexpectedExecutorLogLevel(void *context) {
359359
#if SWIFT_STDLIB_HAS_ENVIRON

test/Concurrency/Runtime/data_race_detection.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
// RUN: %target-run-simple-swift( -Xfrontend -disable-availability-checking -enable-actor-data-race-checks %import-libdispatch -parse-as-library) > %t.log 2>&1
2-
// RUN: %FileCheck %s < %t.log
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-build-swift %import-libdispatch -Xfrontend -disable-availability-checking -enable-actor-data-race-checks -parse-as-library -I %t %s -o %t/a.out -module-name main
3+
// RUN: %target-codesign %t/a.out
4+
// RUN: env %env-SWIFT_UNEXPECTED_EXECUTOR_LOG_LEVEL=1 %target-run %t/a.out 2>&1 | %FileCheck %s
5+
6+
// Make sure that without downgrade the program crashes by default
7+
// RUN: not --crash %target-run %t/a.out 2>&1
38

49
// REQUIRES: executable_test
510
// REQUIRES: concurrency
@@ -59,14 +64,14 @@ actor MyActor {
5964
struct Runner {
6065
static func main() async {
6166
print("Launching a main-actor task")
62-
// CHECK: warning: data race detected: @MainActor function at main/data_race_detection.swift:23 was not called on the main thread
67+
// CHECK: warning: data race detected: @MainActor function at main/data_race_detection.swift:28 was not called on the main thread
6368
launchFromMainThread()
6469
sleep(1)
6570

6671
let actor = MyActor()
6772
let actorFn = await actor.getTaskOnMyActor()
6873
print("Launching an actor-instance task")
69-
// CHECK: warning: data race detected: actor-isolated function at main/data_race_detection.swift:52 was not called on the same actor
74+
// CHECK: warning: data race detected: actor-isolated function at main/data_race_detection.swift:57 was not called on the same actor
7075
launchTask(actorFn)
7176

7277
sleep(1)

0 commit comments

Comments
 (0)