Hi tera, Thanks so much for your reply! I disabled all of the diagnostics and relaunched the app, but it crashed in the same way.
Then I ran it with the Profiler, with the Time Profiling template, and it crashed in the same way. Here's an excerpt from the crash report:
...
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000018017ef14
Termination Reason: SIGNAL 5 Trace/BPT trap: 5
Terminating Process: exc handler [24660]
Triggered by Thread: 6
...
Thread 6 Crashed:
0 libdispatch.dylib 0x18017ef14 _dispatch_assert_queue_fail + 116
1 libdispatch.dylib 0x18017eea0 dispatch_assert_queue + 188
2 libswift_Concurrency.dylib 0x2495b7400 swift_task_isCurrentExecutorImpl(swift::SerialExecutorRef) + 284
3 Applin Example 0x10218a038 specialized thunk for @escaping @callee_guaranteed (@guaranteed ApplinConfig, @guaranteed String) -> (@out ToPageSpec) + 132
4 Applin Example 0x1021af394 thunk for @escaping @callee_guaranteed (@in_guaranteed ApplinConfig, @in_guaranteed String) -> (@out ToPageSpec) + 28 [inlined]
5 Applin Example 0x1021af394 ApplinConfig.staticPageSpec(pageKey:) + 28 (ApplinConfig.swift:79) [inlined]
6 Applin Example 0x1021af394 PageStack.fetchPageSpec(_:pageKey:) + 168 (PageStack.swift:309)
7 Applin Example 0x1021afb81 PageStack.doPushAction(pageKey:) + 1 (PageStack.swift:342)
8 Applin Example 0x1021b5619 specialized PageStack.handleInteractiveError(_:) + 1
9 Applin Example 0x102201149 closure #1 in FormButtonWidget.tap() + 1 (form_button.swift:111)
10 Applin Example 0x10218f3fd partial apply for specialized thunk for @escaping @isolated(any) @callee_guaranteed @async () -> (@out A) + 1
11 Applin Example 0x10219004d specialized thunk for @escaping @isolated(any) @callee_guaranteed @async () -> (@out A) + 1
12 Applin Example 0x102190045 partial apply for specialized thunk for @escaping @isolated(any) @callee_guaranteed @async () -> (@out A) + 1
13 libswift_Concurrency.dylib 0x2495bc829 completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*) + 1
...
Your comment got me looking closer at the stack trace. Sadly, XCode doesn't come with the source code for UIKit or the swift libs. I searched for the function swift_task_isCurrentExecutorImpl
and found some info online that seems to explain the problem:
- Crash when running in Swift 6 language mode
- Actor `assumeIsolated` erroneously crashes when using a dispatch queue as the underlying executor - #6 by Karl
- DispatchSource crash under swift 6
- Why no compiler error for this Swift Concurrency/Combine code? - #3 by edu.art
- Documentation / Migrating to Swift 6 / Incremental Adoption
It looks like Swift 6 compiles code with no warnings but crashes at runtime with no error message. I hope they fix that.
There is a strange claim in the docs:
Note: It is not possible for the compiler to detect or diagnose the lack of compiler-visible information.
It seems like a limitation of the type system.