Skip to content

Commit 8f974c1

Browse files
authored
Merge pull request swiftlang#36524 from etcwilde/ewilde/fix-after-main-crash
[Concurrency] Make asyncMainDrainQueue noreturn
2 parents 591bd6a + b0b4cb6 commit 8f974c1

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

include/swift/Runtime/Concurrency.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ void swift_continuation_logFailedCheck(const char *message);
537537
/// If the binary links CoreFoundation, uses CFRunLoopRun
538538
/// Otherwise it uses dispatchMain.
539539
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
540-
void swift_task_asyncMainDrainQueue();
540+
void swift_task_asyncMainDrainQueue [[noreturn]]();
541541

542542
/// Establish that the current thread is running as the given
543543
/// executor, then run a job.

stdlib/public/Concurrency/Task.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,7 @@ void swift::swift_task_asyncMainDrainQueue() {
828828
abort();
829829

830830
pfndispatch_main();
831+
exit(0);
831832
#else
832833
// CFRunLoop is not available on non-Darwin targets. Foundation has an
833834
// implementation, but CoreFoundation is not meant to be exposed. We can only
@@ -836,8 +837,10 @@ void swift::swift_task_asyncMainDrainQueue() {
836837
#if defined(__APPLE__)
837838
auto runLoop =
838839
reinterpret_cast<void (*)(void)>(dlsym(RTLD_DEFAULT, "CFRunLoopRun"));
839-
if (runLoop)
840-
return runLoop();
840+
if (runLoop) {
841+
runLoop();
842+
exit(0);
843+
}
841844
#endif
842845

843846
dispatch_main();

0 commit comments

Comments
 (0)