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-6853] Segfault when two cases have the same name in an enum with generated Equatable conformance #49402

Closed
swift-ci opened this issue Jan 26, 2018 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself conformances Feature → protocol: protocol conformances crash Bug: A crash, i.e., an abnormal termination of software declarations Feature: declarations derived conformances Feature → protocol → conformances: derived conformances aka synthesized conformances enum cases Feature → enums: Enum cases enum Feature → type declarations: Swift enumeration declarations Equatable Area → standard library: The `Equatable` protocol overloading Feature: Overloading symbol names protocol Feature → type declarations: Protocol declarations swift 4.1 type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jan 26, 2018

Previous ID SR-6853
Radar rdar://problem/36989792
Original Reporter neightchan (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee None
Priority Medium

md5: 803224f888a9a93b76da1719e3f9bb9e

Issue Description:

In Xcode 9Q98q, the following code

enum E : Equatable {
    case c(Int)
    case c(String)
}

results in the following segfault:

/Users/nchandle/Work/Scratchpads/BoxDemo/BoxDemo/main.swift:15:10: error: duplicate definition of enum element
    case a(String)
         ^
/Users/nchandle/Work/Scratchpads/BoxDemo/BoxDemo/main.swift:14:10: note: previous definition of 'a' is here
    case a(Int)
         ^
0  swift                    0x00000001118a678a PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x00000001118a5b46 SignalHandler(int) + 966
2  libsystem_platform.dylib 0x00007fff70414f5a _sigtramp + 26
3  libsystem_platform.dylib 0x0000000112d2de00 _sigtramp + 2727448256
4  swift                    0x000000010eebf73d enumElementPayloadSubpattern(swift::EnumElementDecl*, char, swift::DeclContext*, llvm::SmallVectorImpl<swift::VarDecl*>&) + 173
5  swift                    0x000000010eebcfbc deriveBodyEquatable_enum_hasAssociatedValues_eq(swift::AbstractFunctionDecl*) + 892
6  swift                    0x000000010efb333c swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 60
7  swift                    0x000000010efd5bfb swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int) + 2491
8  swift                    0x000000010ec586e1 swift::CompilerInstance::performSema() + 5585
9  swift                    0x000000010df04a74 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1892
10 swift                    0x000000010df02894 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7908
11 swift                    0x000000010deb72c5 main + 18917
12 libdyld.dylib            0x00007fff70193115 start + 1
Stack dump:
0. Program arguments: /Users/nchandle/Applications/Xcode93Beta1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/nchandle/Work/Scratchpads/BoxDemo/BoxDemo/main.swift -target x86_64-apple-macosx10.13 -enable-objc-interop -sdk /Users/nchandle/Applications/Xcode93Beta1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -I /Users/nchandle/Library/Developer/Xcode/DerivedData/BoxDemo-alifpgeqscitmqasmhdfcjgypcui/Build/Products/Debug -F /Users/nchandle/Library/Developer/Xcode/DerivedData/BoxDemo-alifpgeqscitmqasmhdfcjgypcui/Build/Products/Debug -enable-testing -g -module-cache-path /Users/nchandle/Library/Developer/Xcode/DerivedData/ModuleCache -swift-version 4 -enforce-exclusivity=checked -Onone -D DEBUG -serialize-debugging-options -Xcc -I/Users/nchandle/Library/Developer/Xcode/DerivedData/BoxDemo-alifpgeqscitmqasmhdfcjgypcui/Build/Intermediates.noindex/BoxDemo.build/Debug/BoxDemo.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/nchandle/Library/Developer/Xcode/DerivedData/BoxDemo-alifpgeqscitmqasmhdfcjgypcui/Build/Intermediates.noindex/BoxDemo.build/Debug/BoxDemo.build/BoxDemo-generated-files.hmap -Xcc -I/Users/nchandle/Library/Developer/Xcode/DerivedData/BoxDemo-alifpgeqscitmqasmhdfcjgypcui/Build/Intermediates.noindex/BoxDemo.build/Debug/BoxDemo.build/BoxDemo-own-target-headers.hmap -Xcc -I/Users/nchandle/Library/Developer/Xcode/DerivedData/BoxDemo-alifpgeqscitmqasmhdfcjgypcui/Build/Intermediates.noindex/BoxDemo.build/Debug/BoxDemo.build/BoxDemo-all-target-headers.hmap -Xcc -iquote -Xcc /Users/nchandle/Library/Developer/Xcode/DerivedData/BoxDemo-alifpgeqscitmqasmhdfcjgypcui/Build/Intermediates.noindex/BoxDemo.build/Debug/BoxDemo.build/BoxDemo-project-headers.hmap -Xcc -I/Users/nchandle/Library/Developer/Xcode/DerivedData/BoxDemo-alifpgeqscitmqasmhdfcjgypcui/Build/Products/Debug/include -Xcc -I/Users/nchandle/Library/Developer/Xcode/DerivedData/BoxDemo-alifpgeqscitmqasmhdfcjgypcui/Build/Intermediates.noindex/BoxDemo.build/Debug/BoxDemo.build/DerivedSources/x86_64 -Xcc -I/Users/nchandle/Library/Developer/Xcode/DerivedData/BoxDemo-alifpgeqscitmqasmhdfcjgypcui/Build/Intermediates.noindex/BoxDemo.build/Debug/BoxDemo.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/nchandle/Work/Scratchpads/BoxDemo -emit-module-doc-path /Users/nchandle/Library/Developer/Xcode/DerivedData/BoxDemo-alifpgeqscitmqasmhdfcjgypcui/Build/Intermediates.noindex/BoxDemo.build/Debug/BoxDemo.build/Objects-normal/x86_64/main~partial.swiftdoc -serialize-diagnostics-path /Users/nchandle/Library/Developer/Xcode/DerivedData/BoxDemo-alifpgeqscitmqasmhdfcjgypcui/Build/Intermediates.noindex/BoxDemo.build/Debug/BoxDemo.build/Objects-normal/x86_64/main.dia -module-name BoxDemo -emit-module-path /Users/nchandle/Library/Developer/Xcode/DerivedData/BoxDemo-alifpgeqscitmqasmhdfcjgypcui/Build/Intermediates.noindex/BoxDemo.build/Debug/BoxDemo.build/Objects-normal/x86_64/main~partial.swiftmodule -emit-dependencies-path /Users/nchandle/Library/Developer/Xcode/DerivedData/BoxDemo-alifpgeqscitmqasmhdfcjgypcui/Build/Intermediates.noindex/BoxDemo.build/Debug/BoxDemo.build/Objects-normal/x86_64/main.d -emit-reference-dependencies-path /Users/nchandle/Library/Developer/Xcode/DerivedData/BoxDemo-alifpgeqscitmqasmhdfcjgypcui/Build/Intermediates.noindex/BoxDemo.build/Debug/BoxDemo.build/Objects-normal/x86_64/main.swiftdeps -o /Users/nchandle/Library/Developer/Xcode/DerivedData/BoxDemo-alifpgeqscitmqasmhdfcjgypcui/Build/Intermediates.noindex/BoxDemo.build/Debug/BoxDemo.build/Objects-normal/x86_64/main.o -index-store-path /Users/nchandle/Library/Developer/Xcode/DerivedData/BoxDemo-alifpgeqscitmqasmhdfcjgypcui/Index/DataStore -index-system-modules 
1. While type-checking '__derived_enum_equals(_:_:)' in module 'BoxDemo'
@belkadan
Copy link
Contributor

@swift-ci create

@belkadan
Copy link
Contributor

Pavel fixed this and cherry-picked it to Swift 4.1 in #14433

@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
@AnthonyLatsis AnthonyLatsis added conformances Feature → protocol: protocol conformances derived conformances Feature → protocol → conformances: derived conformances aka synthesized conformances swift 4.1 enum Feature → type declarations: Swift enumeration declarations protocol Feature → type declarations: Protocol declarations Equatable Area → standard library: The `Equatable` protocol enum case overloading enum cases Feature → enums: Enum cases labels May 4, 2023
@AnthonyLatsis AnthonyLatsis added overloading Feature: Overloading symbol names declarations Feature: declarations type checker Area → compiler: Semantic analysis and removed enum case overloading labels May 16, 2023
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 conformances Feature → protocol: protocol conformances crash Bug: A crash, i.e., an abnormal termination of software declarations Feature: declarations derived conformances Feature → protocol → conformances: derived conformances aka synthesized conformances enum cases Feature → enums: Enum cases enum Feature → type declarations: Swift enumeration declarations Equatable Area → standard library: The `Equatable` protocol overloading Feature: Overloading symbol names protocol Feature → type declarations: Protocol declarations swift 4.1 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants