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-10761] swiftc crash (regression from 4.2): protocol inheriting a protocol imported via @testable and redefining an inherited property #53151

Closed
mayoff opened this issue May 23, 2019 · 2 comments
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 regression swift 5.0

Comments

@mayoff
Copy link

mayoff commented May 23, 2019

Previous ID SR-10761
Radar rdar://problem/51108930
Original Reporter @mayoff
Type Bug
Status Closed
Resolution Done

Attachment: Download

Environment
  • macOS 10.14.6 Beta (18G29g)

  • Swift trunk snapshot May 21

:; swift -version
Apple Swift version 5.1-dev (LLVM 082dec2e22, Swift fc0ab61888)
Target: x86_64-apple-darwin18.6.0
:; uname -a
Darwin wmp-rmayoff02 18.6.0 Darwin Kernel Version 18.6.0: Tue May  7 22:54:55 PDT 2019; root:xnu-4903.270.19.100.1~2/RELEASE_X86_64 x86_64
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 5.0Regression, CompilerCrash
Assignee None
Priority Medium

md5: 4bb05246cf74782cf73a99aad36ac4f7

Issue Description:

The attached archive (bug.zip) contains a Swift PM project that defines a library target (“TheModule”) and a test target (“TheModuleTests”).

The library TheModule defines a single protocol containing a single get-only property. This is the entire source of the library TheModule:

protocol BaseProtocol {
    var theProperty: String { get }
}

The test target TheModuleTests imports TheModule with @testable. It defines a protocol that inherits from the protocol in TheModule and redefines the property to be get-and-set. This is the entire source of the test target TheModuleTests:

@testable import TheModule

protocol SubProtocol: BaseProtocol {
    var theProperty: String { get set }
}

swiftc crashes while compiling the test target:

:; rm -rf .build; TOOLCHAINS=org.swift.50201905211a swift test
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2019-05-21-a.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/rmayoff/P/clarity/bug/Tests/TheModuleTests/TheModuleTests.swift /Users/rmayoff/P/clarity/bug/Tests/TheModuleTests/XCTestManifests.swift -emit-module-path /Users/rmayoff/P/clarity/bug/.build/x86_64-apple-macosx/debug/TheModuleTests.build/TheModuleTests~partial.swiftmodule -emit-module-doc-path /Users/rmayoff/P/clarity/bug/.build/x86_64-apple-macosx/debug/TheModuleTests.build/TheModuleTests~partial.swiftdoc -emit-dependencies-path /Users/rmayoff/P/clarity/bug/.build/x86_64-apple-macosx/debug/TheModuleTests.build/TheModuleTests.d -emit-reference-dependencies-path /Users/rmayoff/P/clarity/bug/.build/x86_64-apple-macosx/debug/TheModuleTests.build/TheModuleTests.swiftdeps -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode-10.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I /Users/rmayoff/P/clarity/bug/.build/x86_64-apple-macosx/debug -F /Applications/Xcode-10.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -enable-testing -g -module-cache-path /Users/rmayoff/P/clarity/bug/.build/x86_64-apple-macosx/debug/ModuleCache -swift-version 4.2 -Onone -D SWIFT_PACKAGE -D DEBUG -color-diagnostics -enable-anonymous-context-mangled-names -parse-as-library -module-name TheModuleTests -o /Users/rmayoff/P/clarity/bug/.build/x86_64-apple-macosx/debug/TheModuleTests.build/TheModuleTests.swift.o -index-store-path /Users/rmayoff/P/clarity/bug/.build/x86_64-apple-macosx/debug/index/store -index-system-modules 
1.  Apple Swift version 5.1-dev (LLVM 082dec2e22, Swift fc0ab61888)
2.  While type-checking 'SubProtocol' (at /Users/rmayoff/P/clarity/bug/Tests/TheModuleTests/TheModuleTests.swift:3:1)
3.  While type-checking declaration 0x7f8d890b8f58 (at /Users/rmayoff/P/clarity/bug/Tests/TheModuleTests/TheModuleTests.swift:4:5)
0  swift                    0x0000000111003df5 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x00000001110030b5 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x00000001110043d8 SignalHandler(int) + 264
3  libsystem_platform.dylib 0x00007fff5ee7db5d _sigtramp + 29
4  libsystem_platform.dylib 0x0000000000000001 _sigtramp + 2702714049
5  swift                    0x000000010dfd0f93 (anonymous namespace)::OverrideMatcher::checkOverride(swift::ValueDecl*, (anonymous namespace)::OverrideCheckingAttempt) + 723
6  swift                    0x000000010dfceb1f (anonymous namespace)::OverrideMatcher::checkPotentialOverrides(llvm::SmallVectorImpl<(anonymous namespace)::OverrideMatch>&, (anonymous namespace)::OverrideCheckingAttempt) + 175
7  swift                    0x000000010dfcdc93 swift::checkOverrides(swift::ValueDecl*) + 755
8  swift                    0x000000010dfbb213 void llvm::function_ref<void (swift::VarDecl*)>::callback_fn<(anonymous namespace)::DeclChecker::visitBoundVars(swift::Pattern*)::'lambda'(swift::VarDecl*)>(long, swift::VarDecl*) + 643
9  swift                    0x000000010dfa8a7f (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 1919
10 swift                    0x000000010dfb632b (anonymous namespace)::DeclChecker::visitProtocolDecl(swift::ProtocolDecl*) + 523
11 swift                    0x000000010dfa89be (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 1726
12 swift                    0x000000010dfa82f6 swift::TypeChecker::typeCheckDecl(swift::Decl*) + 38
13 swift                    0x000000010e051dfc swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 956
14 swift                    0x000000010d795672 swift::CompilerInstance::parseAndCheckTypesUpTo(swift::CompilerInstance::ImplicitImports const&, swift::SourceFile::ASTStage_t) + 530
15 swift                    0x000000010d794da7 swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 615
16 swift                    0x000000010d55ed22 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1666
17 swift                    0x000000010d55d631 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3025
18 swift                    0x000000010d503979 main + 729
19 libdyld.dylib            0x00007fff5ec923d5 start + 1

The test target compiles successfully using Swift 4.2:

:; rm -rf .build; TOOLCHAINS=org.swift.4220181030a swift test
Compile Swift Module 'TheModule' (1 sources)
Compile Swift Module 'TheModuleTests' (2 sources)
Linking ./.build/x86_64-apple-macosx10.10/debug/TheModulePackageTests.xctest/Contents/MacOS/TheModulePackageTests
Test Suite 'All tests' started at 2019-05-23 15:14:22.411
Test Suite 'All tests' passed at 2019-05-23 15:14:22.411.
     Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.000) seconds
@slavapestov
Copy link
Member

#25446

@mayoff
Copy link
Author

mayoff commented Jul 13, 2019

Verified in swift-DEVELOPMENT-SNAPSHOT-2019-07-11-a.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
This issue was closed.
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 regression swift 5.0
Projects
None yet
Development

No branches or pull requests

3 participants