Skip to content

Commit 99064c3

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 f0f8e9b commit 99064c3

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

stdlib/public/Concurrency/Actor.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -351,15 +351,14 @@ 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 (strcmp(modeStr, "nocrash") == 0) {
357+
useLegacyMode = Legacy_NoCheckIsolated_NonCrashing;
358+
} else if (strcmp(modeStr, "crash") == 0) {
359+
useLegacyMode = Default_UseCheckIsolated_AllowCrash;
360+
} // else, just use the platform detected mode
361+
}
363362
#endif // SWIFT_STDLIB_HAS_ENVIRON
364363
isCurrentExecutorMode = useLegacyMode ? Legacy_NoCheckIsolated_NonCrashing
365364
: Default_UseCheckIsolated_AllowCrash;

0 commit comments

Comments
 (0)