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-9398] Use-after-free caused by iterator invalidation in GSB::removeSelfDerived() #51864

Closed
nsalmoria opened this issue Dec 2, 2018 · 1 comment
Assignees
Labels
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 multiple files Flag: An issue whose reproduction requires multiple files regression swift 5.0

Comments

@nsalmoria
Copy link
Contributor

Previous ID SR-9398
Radar rdar://problem/46420886
Original Reporter @nsalmoria
Type Bug
Environment

macOS 10.14.1, Xcode 10.1, development snapshot 2018-11-28.

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 5.0Regression, CompilerCrash, MultiFile
Assignee @slavapestov
Priority Medium

md5: baff34e3ae04331377fed4a62040334b

is duplicated by:

  • SR-12616 Compiler crasher while type checking generic code while evaluating generic signatures

Issue Description:

This is a regression that happened between toolchain 2018-11-26 and 2018-11-28.

The code compiles fine with 2018-11-26. It crashes the compiler with 2018-11-28.

The crash happens only when the source is split over two files.

In main.swift:

struct Crasher<Base1: Foo, Base2: Foo> where Base1.Type1 == Base2.Type2 {
}

in a separate file:

protocol Foo {
    associatedtype Type1
    associatedtype Type2: Foo where Type2.Type1 == Type1, Type2.Type3 == Type3
    associatedtype Type3: Sequence where Type3.Element == Type1
}

Interestingly, changing the declaration order of the associated types so that Type3 is declared before Type2 fixes the crash.

This is the crash log:

1.  While type-checking 'Crasher' (at /Users/nicolasalmoria/Documents/BugReportCompilerCrash2/VeniceConnection/main.swift:1:1)
2.  While validating 'Crasher' (at /Users/nicolasalmoria/Documents/BugReportCompilerCrash2/VeniceConnection/main.swift:1:1)
0  swift                    0x000000010744e428 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x000000010744d6a5 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x000000010744ea32 SignalHandler(int) + 258
3  libsystem_platform.dylib 0x00007fff62393b3d _sigtramp + 29
4  libsystem_platform.dylib 0x718593f800000005 _sigtramp + 2647049445
5  swift                    0x0000000104bb1f84 swift::GenericSignatureBuilder::checkConformanceConstraints(swift::ArrayRefView<swift::Type, swift::GenericTypeParamType*, swift::GenericTypeParamType* swift::staticCastHelper<swift::GenericTypeParamType>(swift::Type const&), true>, swift::GenericSignatureBuilder::EquivalenceClass*) + 100
6  swift                    0x0000000104bb00e7 swift::GenericSignatureBuilder::finalize(swift::SourceLoc, swift::ArrayRefView<swift::Type, swift::GenericTypeParamType*, swift::GenericTypeParamType* swift::staticCastHelper<swift::GenericTypeParamType>(swift::Type const&), true>, bool) + 775
7  swift                    0x0000000104bb8fcd swift::GenericSignatureBuilder::computeGenericSignature(swift::SourceLoc, bool, bool) && + 45
8  swift                    0x000000010486c789 swift::TypeChecker::checkGenericEnvironment(swift::GenericParamList*, swift::DeclContext*, swift::GenericSignature*, bool, swift::ExtensionDecl*, llvm::function_ref<void (swift::GenericSignatureBuilder&)>, bool) + 1225
9  swift                    0x000000010486cece swift::TypeChecker::validateGenericTypeSignature(swift::GenericTypeDecl*) + 382
10 swift                    0x000000010483da78 swift::TypeChecker::validateDecl(swift::ValueDecl*) + 648
11 swift                    0x0000000104847224 (anonymous namespace)::DeclChecker::visitStructDecl(swift::StructDecl*) + 84
12 swift                    0x000000010483a933 (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 1491
13 swift                    0x000000010483a356 swift::TypeChecker::typeCheckDecl(swift::Decl*) + 38
14 swift                    0x00000001048d6928 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 872
15 swift                    0x00000001040ad8dc swift::CompilerInstance::parseAndTypeCheckMainFileUpTo(swift::SourceFile::ASTStage_t, swift::PersistentParserState&, swift::DelayedParsingCallbacks*, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>) + 492
16 swift                    0x00000001040ac253 swift::CompilerInstance::parseAndCheckTypesUpTo(swift::CompilerInstance::ImplicitImports const&, swift::SourceFile::ASTStage_t) + 435
17 swift                    0x00000001040ab918 swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 616
18 swift                    0x000000010388d7dd performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1309
19 swift                    0x000000010388c22d swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3021
20 swift                    0x000000010383e05e main + 686
21 libdyld.dylib            0x00007fff621aa08d start + 1
error: Segmentation fault: 11
@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@slavapestov
Copy link
Member

GSB bugs should all be fixed in 5.7 because the GSB is gone.

@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
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 multiple files Flag: An issue whose reproduction requires multiple files regression swift 5.0
Projects
None yet
Development

No branches or pull requests

3 participants