mirror of
https://github.com/apple/swift.git
synced 2026-11-20 05:27:31 +01:00
When an exception is thrown through swift_job_run, it leaves the Concurrency runtime in an inconsistent state, which can lead to misbehavior or crashes later on. It's very difficult to work out what the cause is when this happens. Since the program state is doomed once this happens, prevent exceptions from propagating through swift_job_run at all, and terminate immediately when throwing. rdar://171909991
33 lines
718 B
Swift
33 lines
718 B
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-build-swift -import-objc-header %S/Inputs/ObjCExceptionHelpers.h %s -o %t/a.out
|
|
// RUN: %target-codesign %t/a.out
|
|
// RUN: %target-run %t/a.out
|
|
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: concurrency
|
|
// REQUIRES: concurrency_runtime
|
|
// REQUIRES: objc_interop
|
|
|
|
// UNSUPPORTED: back_deployment_runtime
|
|
|
|
import Foundation
|
|
import StdlibUnittest
|
|
|
|
var tests = TestSuite("ObjCExceptionInTask")
|
|
|
|
tests.test("exception terminates in swift_job_runImpl") {
|
|
expectCrashLater()
|
|
|
|
Task { @MainActor in
|
|
ThrowObjCException()
|
|
}
|
|
|
|
_ = CatchingException {
|
|
RunLoop.current.run()
|
|
}
|
|
|
|
expectUnreachable("Exception should not propagate through swift_job_runImpl")
|
|
}
|
|
|
|
runAllTests()
|