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-13006] Segmentation fault when type checking recursive dynamicMemberLookup #55451

Closed
jadengeller mannequin opened this issue Jun 13, 2020 · 3 comments
Closed

[SR-13006] Segmentation fault when type checking recursive dynamicMemberLookup #55451

jadengeller mannequin opened this issue Jun 13, 2020 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@jadengeller
Copy link
Mannequin

jadengeller mannequin commented Jun 13, 2020

Previous ID SR-13006
Radar None
Original Reporter @JadenGeller
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

Environment

Apple Swift version 5.2 (swiftlang-1103.0.32.1 clang-1103.0.32.29)

Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee None
Priority Medium

md5: cfc88b8c12ca1447b97e52e2703b14dd

duplicates:

  • SR-12425 Swift 5.2 Regression: Segfault when type of dynamic member key path doesn't match instance type

Issue Description:

Minimal example:

@dynamicMemberLookup indirect enum Patched<Root> {
    case patched(Patched<Root>)
    
    subscript<Value>(dynamicMember member: KeyPath<Root, Value>) -> Value {
        switch self {
            case .patched(let root): 
                return root[keyPath: member]
        }
    }
} 

Failure:

Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file Untitled 4.swift -target x86_64-apple-darwin19.5.0 -enable-objc-interop -stack-check -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -module-name main -o /var/folders/4k/m4ntdp9n6hncmrp8kmhw515r0000gn/T/Untitled 4-dd2419.o 
1.  Apple Swift version 5.2 (swiftlang-1103.0.32.1 clang-1103.0.32.29)
2.  While evaluating request TypeCheckSourceFileRequest(source_file "Untitled 4.swift", 0)
3.  While evaluating request TypeCheckFunctionBodyUntilRequest(main.(file).Patched._@Untitled 4.swift:4:72, )
4.  While type-checking getter for subscript(dynamicMember:) (at Untitled 4.swift:4:2)
5.  While type-checking statement at [Untitled 4.swift:4:72 - line:9:2] RangeText="{
        switch self {
            case .patched(let root): 
                return root[keyPath: member]
        }
    "
6.  While type-checking statement at [Untitled 4.swift:5:3 - line:8:3] RangeText="switch self {
            case .patched(let root): 
                return root[keyPath: member]
        "
7.  While type-checking statement at [Untitled 4.swift:7:5 - line:7:32] RangeText="return root[keyPath: member"
8.  While type-checking statement at [Untitled 4.swift:7:5 - line:7:32] RangeText="return root[keyPath: member"
9.  While type-checking expression at [Untitled 4.swift:7:12 - line:7:32] RangeText="root[keyPath: member"
0  swift                    0x000000010761d4ea PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x000000010761ccc0 SignalHandler(int) + 352
2  libsystem_platform.dylib 0x00007fff6c3965fd _sigtramp + 29
3  libsystem_platform.dylib 0x00007ffeec931af8 _sigtramp + 2153362712
4  swift                    0x0000000103db3775 (anonymous namespace)::ExprRewriter::buildKeyPathDynamicMemberIndexExpr(swift::BoundGenericType*, swift::SourceLoc, swift::constraints::ConstraintLocator*) + 2645
5  swift                    0x0000000103da8288 (anonymous namespace)::ExprRewriter::buildDynamicMemberLookupRef(swift::Expr*, swift::Expr*, swift::SourceLoc, swift::SourceLoc, swift::constraints::SelectedOverload const&, swift::constraints::ConstraintLocator*) + 568
6  swift                    0x0000000103d9707c swift::ASTVisitor<(anonymous namespace)::ExprRewriter, swift::Expr*, void, void, void, void, void>::visit(swift::Expr*) + 7948
7  swift                    0x0000000103d950b2 (anonymous namespace)::ExprWalker::walkToExprPost(swift::Expr*) + 18
8  swift                    0x0000000103d8ba98 swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::Expr*, swift::Type, bool, bool) + 7192
9  swift                    0x0000000103f4eac9 swift::TypeChecker::typeCheckExpressionImpl(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener&, swift::constraints::ConstraintSystem*) + 1033
10 swift                    0x0000000104020b3e swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 20782
11 swift                    0x00000001040222a9 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::Stmt>(swift::Stmt*&) + 121
12 swift                    0x000000010401d834 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 7716
13 swift                    0x00000001040222a9 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::Stmt>(swift::Stmt*&) + 121
14 swift                    0x000000010401d501 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 6897
15 swift                    0x00000001040222a9 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::Stmt>(swift::Stmt*&) + 121
16 swift                    0x000000010401d834 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 7716
17 swift                    0x000000010401b3a9 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 121
18 swift                    0x00000001040132ff swift::SimpleRequest<swift::TypeCheckFunctionBodyUntilRequest, bool (swift::AbstractFunctionDecl*, swift::SourceLoc), (swift::CacheKind)1>::evaluateRequest(swift::TypeCheckFunctionBodyUntilRequest const&, swift::Evaluator&) + 2879
19 swift                    0x0000000104019b6e swift::TypeCheckFunctionBodyUntilRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyUntilRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyUntilRequest, swift::TypeCheckFunctionBodyUntilRequest::OutputType) + 718
20 swift                    0x00000001040486ce swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*, unsigned int) const + 6270
21 swift                    0x0000000104017b47 swift::SimpleRequest<swift::TypeCheckSourceFileRequest, bool (swift::SourceFile*, unsigned int), (swift::CacheKind)2>::evaluateRequest(swift::TypeCheckSourceFileRequest const&, swift::Evaluator&) + 23
22 swift                    0x0000000104045fce swift::performTypeChecking(swift::SourceFile&, unsigned int) + 1006
23 swift                    0x000000010367a05b swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 5915
24 swift                    0x00000001033662c9 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 10281
25 swift                    0x00000001032e74d3 main + 1283
26 libdyld.dylib            0x00007fff6c19dcc9 start + 1
<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: compile command failed due to signal 11 (use -v to see invocation)
@LucianoPAlmeida
Copy link
Collaborator

I believe the crash was fixed by https://github.com/apple/swift/pull/31140/

On master snapshot from 2020-05-22 I'm seeing

@LucianoPAlmeida
Copy link
Collaborator

Resolving as duplicated 🙂

cc @xedin

@xedin
Copy link
Member

xedin commented Jun 15, 2020

Thank you!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 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.
Projects
None yet
Development

No branches or pull requests

2 participants