Swift 6.2 ready for isolated deinit?

Shouldn’t the following code compile? However, I still encounter a runtime crash of the compiler in debug mode (Xcode 26 Beta 2).

import UIKit

class MyView: UIView {
  isolated deinit {}
}

This issue has also been reported as FB18013739.

Should be.

If there is no sensitive information, could you pls also report it as a GitHub issue? I could take a look, but I don't have access to Apple's bug tracker.

1 Like

Yeah it's always preferable to file a github issue for Swift issues (which Apple folks like myself can sync to internal system). Issues with frameworks that come with the OS should be filed using Feedback Assistant since they're not on github ofc.

The reproducer is just that though:

Both these crash:


class FakeUIView: NSObject { }
@MainActor class Bar: FakeUIView { // crash
    isolated deinit {
    }
}
@MainActor open
class FakeMainActorUIView: NSObject { }
class Test: FakeMainActorUIView { // crash
    isolated deinit {
    }
}
1.	Apple Swift version 6.2 
2.	Compiling with effective version 5.10
3.	While evaluating request ASTLoweringRequest(Lowering AST to SIL for module Isolated)
4.	While silgen emitDestructor -dealloc SIL function "@$s8Isolated3BarCfZ".
 for 'deinit' (at .../Isolated/Isolated/IsolatedApp.swift:16:14)
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x0000000106f69eb8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000106f67848 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000106f6a4e4 SignalHandler(int, __siginfo*, void*) + 344
3  libsystem_platform.dylib 0x000000018c1b3624 _sigtramp + 56
4  swift-frontend           0x00000001017311e4 swift::Lowering::SILGenFunction::emitObjCDestructor(swift::SILDeclRef) + 468
5  swift-frontend           0x00000001017311e4 swift::Lowering::SILGenFunction::emitObjCDestructor(swift::SILDeclRef) + 468
6  swift-frontend           0x00000001016b2328 swift::Lowering::SILGenModule::emitDeallocatorImpl(swift::SILDeclRef, swift::SILFunction*) + 1484
7  swift-frontend           0x00000001016b0e0c swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 5656
8  swift-frontend           0x00000001016b3cfc swift::Lowering::SILGenModule::emitObjCAllocatorDestructor(swift::ClassDecl*, swift::DestructorDecl*) + 152
9  swift-frontend           0x00000001016b42d8 swift::Lowering::SILGenModule::emitDestructor(swift::ClassDecl*, swift::DestructorDecl*) + 564
10 swift-frontend           0x0000000101812330 (anonymous namespace)::SILGenType::emitType() + 568
11 swift-frontend           0x00000001016af4f4 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 100
12 swift-frontend           0x00000001016b6368 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 2364
13 swift-frontend           0x00000001017f969c swift::SimpleRequest<swift::ASTLoweringRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>> (swift::ASTLoweringDescriptor), (swift::RequestFlags)17>::evaluateRequest(swift::ASTLoweringRequest const&, swift::Evaluator&) + 208
14 swift-frontend           0x00000001016badf0 swift::ASTLoweringRequest::OutputType swift::Evaluator::getResultUncached<swift::ASTLoweringRequest, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()>(swift::ASTLoweringRequest const&, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()) + 572
15 swift-frontend           0x0000000100bd86f4 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 2616
16 swift-frontend           0x0000000100bdb3f4 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1764
17 swift-frontend           0x0000000100bda004 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3580
18 swift-frontend           0x0000000100b5b698 swift::mainEntry(int, char const**) + 5412
19 dyld                     0x000000018bddab4c start + 6000

I’ve created a GitHub issue to support any solution:

Thank you, I gave this a quick look and added some info into the radar - sounds like @Nickolas_Pohilets you could give it a look? I can also make time soon to have a deeper look soon. It seems to be specific to inheriting from objective-c classes as far as I can see.

1 Like

I have a fix for this at [SILGen] Ensure that we don't emit a skipped isolated deinit by DougGregor · Pull Request #82545 · swiftlang/swift · GitHub

Doug

3 Likes