I've run into the same problem, and you don't really need @unchecked Sendable to trigger it either, you just need old-fashioned APIs that don't understand Swift concurrency. For instance, I managed to make this minimal test case:
final class TestCrash: XCTestCase {
let subject = CurrentValueSubject<Int, Never>(1)
@MainActor
func testCrash() async throws {
let cancellable = subject.sink { value in
print("\(value)")
}
performSelector(inBackground: #selector(triggerSubject), with: nil) // Crashes
//perform(#selector(triggerSubject), with: nil) // Does not crash
try await Task.sleep(nanoseconds: 1000000000)
_ = cancellable
}
@objc func triggerSubject() {
subject.send(2)
}
}
I feel Swift is being a bit too over-eager to first apply @MainActor and then defend it here.