Skip to content

Commit 6bb72e5

Browse files
committed
[Concurrency] Fix too eager early return in checkIsolation mode detecting
If we have the ability to check env variables, and there was no env variable set we aggressively bailed out of the function's logic, without setting the executor mode at all. This prevented the dynamic modes from working in real (non testing) scenarios. Resolves rdar://127400013
1 parent cae8298 commit 6bb72e5

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

stdlib/public/Concurrency/Actor.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -351,15 +351,16 @@ static void checkIsCurrentExecutorMode(void *context) {
351351

352352
// Potentially, override the platform detected mode, primarily used in tests.
353353
#if SWIFT_STDLIB_HAS_ENVIRON
354-
const char *modeStr = getenv("SWIFT_IS_CURRENT_EXECUTOR_LEGACY_MODE_OVERRIDE");
355-
if (!modeStr)
356-
return;
357-
358-
if (strcmp(modeStr, "nocrash") == 0) {
359-
useLegacyMode = Legacy_NoCheckIsolated_NonCrashing;
360-
} else if (strcmp(modeStr, "crash") == 0) {
361-
useLegacyMode = Default_UseCheckIsolated_AllowCrash;
362-
} // else, just use the platform detected mode
354+
if (const char *modeStr =
355+
getenv("SWIFT_IS_CURRENT_EXECUTOR_LEGACY_MODE_OVERRIDE")) {
356+
if (modeStr && *modeStr) {
357+
if (strcmp(modeStr, "nocrash") == 0) {
358+
useLegacyMode = true;
359+
} else if (strcmp(modeStr, "crash") == 0) {
360+
useLegacyMode = false;
361+
} // else, just use the platform detected mode
362+
}
363+
}
363364
#endif // SWIFT_STDLIB_HAS_ENVIRON
364365
isCurrentExecutorMode = useLegacyMode ? Legacy_NoCheckIsolated_NonCrashing
365366
: Default_UseCheckIsolated_AllowCrash;

0 commit comments

Comments
 (0)