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-13836] Segmentation Fault after error message (invalid code) #56234

Closed
mickeyl opened this issue Nov 8, 2020 · 3 comments
Closed

[SR-13836] Segmentation Fault after error message (invalid code) #56234

mickeyl opened this issue Nov 8, 2020 · 3 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 type checker Area → compiler: Semantic analysis

Comments

@mickeyl
Copy link

mickeyl commented Nov 8, 2020

Previous ID SR-13836
Radar rdar://problem/71167129
Original Reporter @mickeyl
Type Bug
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, TypeChecker
Assignee None
Priority Medium

md5: bd4e99c5608966d4af1caffb68ffecb3

Issue Description:

Here's the offending segment:

final class Whatever {


    static var instance: Self!


    static var shared: Self {
        return instance ?? {
            instance = Self()
            return instance
        }
    }
}

Compiling this breaks with the following backtrace:

Stack dump:Stack dump:0. Program arguments: /Applications/Xcode-12.2.0-release-candidate.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret bug.swift -enable-objc-interop -stack-check -sdk /Applications/Xcode-12.2.0-release-candidate.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk -color-diagnostics -target-sdk-version 11.0 -module-name bug1. Apple Swift version 5.3.1 (swiftlang-1200.0.41 clang-1200.0.32.8)2. While evaluating request TypeCheckSourceFileRequest(source_file "bug.swift")3. While evaluating request TypeCheckFunctionBodyUntilRequest(bug.(file).Whatever._@bug.swift:5:29, )4. While type-checking statement at [bug.swift:5:29 - line:10:5] RangeText="{        return instance ?? {            instance = Self()            return instance        }    "5. While type-checking statement at [bug.swift:6:9 - line:9:9] RangeText="return instance ?? {            instance = Self()            return instance        "6. While type-checking expression at [bug.swift:6:16 - line:9:9] RangeText="instance ?? {            instance = Self()            return instance        "0  swift                    0x0000000107edbc15 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 371  swift                    0x0000000107edc332 SignalHandler(int) + 6102  libsystem_platform.dylib 0x00007fff71daf5fd _sigtramp + 293  libsystem_platform.dylib 0x00007ffeec5b6490 _sigtramp + 184467440714698216164  swift                    0x0000000104475ed6 swift::constraints::Constraint::createDisjunction(swift::constraints::ConstraintSystem&, llvm::ArrayRef<swift::constraints::Constraint*>, swift::constraints::ConstraintLocator*, swift::constraints::RememberChoice_t) + 2305  swift                    0x00000001043caafb swift::constraints::ConstraintSystem::buildDisjunctionForOptionalVsUnderlying(swift::Type, swift::Type, swift::constraints::ConstraintLocator*) + 4916  swift                    0x00000001044960b3 swift::constraints::ConstraintSystem::resolveOverload(swift::constraints::ConstraintLocator*, swift::Type, swift::constraints::OverloadChoice, swift::DeclContext*) + 126917  swift                    0x0000000104408b88 swift::constraints::ConstraintSystem::simplifyConstraint(swift::constraints::Constraint const&) + 13048  swift                    0x00000001043fc763 swift::constraints::ConstraintSystem::simplifyMemberConstraint(swift::constraints::ConstraintKind, swift::Type, swift::DeclNameRef, swift::Type, swift::DeclContext*, swift::FunctionRefKind, llvm::ArrayRef<swift::constraints::OverloadChoice>, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 26279  swift                    0x00000001043baef3 swift::constraints::ConstraintSystem::addValueMemberConstraint(swift::Type, swift::DeclNameRef, swift::Type, swift::DeclContext*, swift::FunctionRefKind, llvm::ArrayRef<swift::constraints::OverloadChoice>, swift::constraints::ConstraintLocatorBuilder) + 9910 swift                    0x00000001043c9b97 (anonymous namespace)::ConstraintGenerator::addMemberRefConstraints(swift::Expr*, swift::Expr*, swift::DeclNameRef, swift::FunctionRefKind, llvm::ArrayRef<swift::ValueDecl*>) + 66311 swift                    0x00000001043c14f0 swift::ASTVisitor<(anonymous namespace)::ConstraintGenerator, swift::Type, void, void, void, void, void>::visit(swift::Expr*) + 1091212 swift                    0x00000001043bc50e (anonymous namespace)::ConstraintWalker::walkToExprPost(swift::Expr*) + 46213 swift                    0x000000010488d5f2 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 211414 swift                    0x000000010488f333 (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 21115 swift                    0x00000001043b5d25 generateConstraintsFor(swift::constraints::ConstraintSystem&, swift::Expr*, swift::DeclContext*) + 50116 swift                    0x00000001043b4404 swift::constraints::ConstraintSystem::generateConstraints(swift::constraints::SolutionApplicationTarget&, swift::FreeTypeVariableBinding) + 45217 swift                    0x00000001044185ee swift::constraints::ConstraintSystem::solve(swift::constraints::SolutionApplicationTarget&, swift::FreeTypeVariableBinding) + 103818 swift                    0x000000010455319f swift::TypeChecker::typeCheckExpression(swift::constraints::SolutionApplicationTarget&, bool&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 83119 swift                    0x0000000104552da8 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 36020 swift                    0x0000000104638055 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 1264521 swift                    0x0000000104638abe bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::Stmt>(swift::Stmt*&) + 35022 swift                    0x00000001046371b4 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 890023 swift                    0x0000000104632afe bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 35024 swift                    0x00000001046314e7 swift::TypeCheckFunctionBodyUntilRequest::evaluate(swift::Evaluator&, swift::AbstractFunctionDecl*, swift::SourceLoc) const + 223125 swift                    0x000000010463a2cd llvm::Expected<swift::TypeCheckFunctionBodyUntilRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckFunctionBodyUntilRequest, (void*)0>(swift::TypeCheckFunctionBodyUntilRequest const&) + 95726 swift                    0x0000000104632588 swift::TypeCheckFunctionBodyUntilRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyUntilRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyUntilRequest, swift::TypeCheckFunctionBodyUntilRequest::OutputType) + 44027 swift                    0x000000010466fd34 swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 138028 swift                    0x0000000104672959 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) + 96929 swift                    0x000000010466f644 swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType) + 16430 swift                    0x0000000103822217 swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 643931 swift                    0x00000001036dfeb5 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 720532 swift                    0x00000001036642c1 main + 126533 libdyld.dylib            0x00007fff71bb2cc9 start + 134 libdyld.dylib            0x000000000000000d start + 18446603338608071493[1]    61312 segmentation fault  swift bug.swift
@typesanitizer
Copy link

@swift-ci create

@LucianoPAlmeida
Copy link
Collaborator

Fixed on master by #34673
@mickeyl Can you please verify the latest main snapshot https://swift.org/download/#snapshots and close? Thanks

@mickeyl
Copy link
Author

mickeyl commented Jul 8, 2021

All good, thanks a lot!

@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

4 participants