Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-8013] Swift 4.2 aborts on ADT with unknown type, can't demangle symbol #50546

Open
swift-ci opened this issue Jun 15, 2018 · 5 comments
Open
Labels
access control Feature → modifiers: Access control and access levels bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software regression swift 4.2

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-8013
Radar rdar://problem/41164792
Original Reporter benpious (JIRA User)
Type Bug
Environment

Xcode 9.3. Toolchain: Swift Development Snapshot 2018-06-08 (a)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 4.2Regression, CompilerCrash
Assignee None
Priority Medium

md5: 70dda8b6d0541d18da9f8c203145673a

Issue Description:

import UIKit

public final class AttributedString {
    
    public enum Attribute {
        case custom(NSAttributedString.Key, Any)
    }
    
}

The code above uses symbols that where renamed between the SDKs that ship with Xcode 9.3 and 9.4, and causes the compiler to abort with the following error message:

Can't demangle: $S6XefBug16AttributedStringC9AttributeO6customXeF
0  swift                    0x0000000112912398 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x00000001129115d7 llvm::sys::RunSignalHandlers() + 39
2  swift                    0x0000000112912a12 SignalHandler(int) + 258
3  libsystem_platform.dylib 0x00007fff72ab5f5a _sigtramp + 26
4  libsystem_platform.dylib 0x000000011676e2d4 _sigtramp + 2748023700
5  libsystem_c.dylib        0x00007fff728e0312 abort + 127
6  swift                    0x00000001103c48d4 swift::Mangle::Mangler::verify(llvm::StringRef) + 980
7  swift                    0x000000011028f83e swift::Mangle::ASTMangler::mangleDeclAsUSR(swift::ValueDecl const*, llvm::StringRef) + 478
8  swift                    0x00000001103bee49 swift::ide::printDeclUSR(swift::ValueDecl const*, llvm::raw_ostream&) + 857
9  swift                    0x000000010fe8b299 (anonymous namespace)::IndexSwiftASTWalker::getNameAndUSR(swift::ValueDecl*, swift::ExtensionDecl*, llvm::StringRef&, llvm::StringRef&) + 505
10 swift                    0x000000010fe8ace2 (anonymous namespace)::IndexSwiftASTWalker::initIndexSymbol(swift::ValueDecl*, swift::SourceLoc, bool, swift::index::IndexSymbol&) + 178
11 swift                    0x000000010fe895c4 (anonymous namespace)::IndexSwiftASTWalker::walkToDeclPre(swift::Decl*, swift::CharSourceRange) + 2196
12 swift                    0x000000010fd0dd80 (anonymous namespace)::SemaAnnotator::walkToDeclPre(swift::Decl*) + 1376
13 swift                    0x00000001102c97a9 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 185
14 swift                    0x00000001102ce46b (anonymous namespace)::Traversal::visitNominalTypeDecl(swift::NominalTypeDecl*) + 475
15 swift                    0x00000001102c9818 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 296
16 swift                    0x00000001102ce46b (anonymous namespace)::Traversal::visitNominalTypeDecl(swift::NominalTypeDecl*) + 475
17 swift                    0x00000001102c9818 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 296
18 swift                    0x00000001102c96db swift::Decl::walk(swift::ASTWalker&) + 27
19 swift                    0x0000000110376c1a swift::SourceFile::walk(swift::ASTWalker&) + 170
20 swift                    0x000000010fd0c677 swift::SourceEntityWalker::walk(swift::SourceFile&) + 119
21 swift                    0x000000010fe88aab (anonymous namespace)::IndexSwiftASTWalker::visitModule(swift::ModuleDecl&, llvm::StringRef) + 235
22 swift                    0x000000010fe88914 swift::index::indexSourceFile(swift::SourceFile*, llvm::StringRef, swift::index::IndexDataConsumer&) + 468
23 swift                    0x000000010fe90b89 recordSourceFileUnit(swift::SourceFile*, llvm::StringRef, llvm::StringRef, bool, bool, llvm::StringRef, llvm::ArrayRef<clang::FileEntry const*>, clang::CompilerInstance const&, swift::DiagnosticEngine&) + 1657
24 swift                    0x000000010fe904fa swift::index::indexAndRecord(swift::SourceFile*, llvm::StringRef, llvm::StringRef, bool, bool, llvm::StringRef, swift::DependencyTracker const&) + 298
25 swift                    0x000000010f117acc emitIndexDataIfNeeded(swift::SourceFile*, swift::CompilerInvocation const&, swift::CompilerInstance&) + 284
26 swift                    0x000000010f10cb54 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 6132
27 swift                    0x000000010f10a2ed swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2973
28 swift                    0x000000010f0c598d main + 2317
29 libdyld.dylib            0x00007fff72834115 start + 1
30 libdyld.dylib            0x0000000000000043 start + 2373762863
Stack dump:
@jckarter
Copy link
Member

@swift-ci create

@belkadan
Copy link
Contributor

Grr. This one's my fault, I guess, but I swear I tested this.

@belkadan
Copy link
Contributor

I wonder if this is only a problem when using a 4.2 toolchain in an Xcode 9.x environment. Ben, do you happen to have an Xcode 10 beta you can compare against? If not, can you attach a self-contained project where this reproduces? (Just to make sure our setup is the same.)

@swift-ci
Copy link
Collaborator Author

Comment by Ben Pious (JIRA)

@belkadan In case you aren't familiar with UIKit, NSAttributedString.Key was renamed from NSAttributedStringKey between the SDKs that ship with 9.x and 10, which is why you definitely wouldn't see it in a "normal" Xcode 10 environment – because you're using an SDK which actually has this symbol.

I did try to repro this in Xcode 10 though by making an objc framework which had an NSObject subclass in it, then trying to use Object.SomeSymbolThatDoesntExist as the type of an associated object of AttributedString.custom in a Swift framework that depended on it, and couldn't reproduce the crash.

I'll try to find a small reproducible case in 9.4 tomorrow, and then see if it also happens in 10. But I think you should be able to get the crash just by switching a 9.3 or 9.4 Xcode installation's SDK to the 4.2 toolchain, then copy pasting the code I already provided into a playground or empty project.

@belkadan
Copy link
Contributor

Thanks for the reminder. It's generally not supported to mix toolchains across major SDK versions, but this is a particularly peculiar crash, so I don't want to just close it.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added regression swift 4.2 access control Feature → modifiers: Access control and access levels and removed 4.2 regression labels Nov 19, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
access control Feature → modifiers: Access control and access levels bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software regression swift 4.2
Projects
None yet
Development

No branches or pull requests

4 participants