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-11663] Code analysis in editor / SourceKit service falls into infinite loop when running certain code #54072

Open
swift-ci opened this issue Oct 24, 2019 · 1 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 performance type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-11663
Radar rdar://problem/56584398
Original Reporter vybo (JIRA User)
Type Bug

Attachment: Download

Environment

Tried on MBP 15-2017, 16GB RAM, macOS 10.14.4 and iMac 5k macOS 10.14.6, both Xcode 11.1.

Additional Detail from JIRA
Votes 0
Component/s Compiler, Source Tooling
Labels Bug, CompilerCrash, Performance, TypeChecker
Assignee None
Priority Medium

md5: 62e1eff4867fe6a0d9eff03e1d355c6c

Issue Description:

I've run into this issue while writing models for our app. Basically editing multiple structures/enums in multiple files at short intervals.

From one moment, SourceKitService started consuming large amounts of memory: pressure at 100%, Activity Monitor shows rapidly growing usage, about 1GB of memory consumed per second, swap around 50 GB until disk is full, then crashing the OS.

Sometimes, when killing SourceKit process, this starts just as "swift" process, or when running as playground it might appear as lldb-rpc service.

SourceKit also stays running and consuming memory after killing Xcode.

It is reproducible every time with the attached playground.

@belkadan
Copy link
Contributor

Looks like it's spinning in the constraint system trying to type-check

        return
            lhs.selectedMode.dateText == rhs.selectedMode.dateText
            && lhs.selectedMode.mode == rhs.selectedMode.mode
            && lhs.modes.enumerated().allSatisfy { mode in
                mode.element.dateText == rhs.modes[mode.offset].dateText
                    && mode.element.mode == rhs.modes[mode.offset].mode
            }
          740 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*)  (in swift) + 6820  [0x106bc5034]
            740 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*)  (in swift) + 815  [0x106bc8b6f]
              740 swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t)  (in swift) + 4679  [0x106ed3037]
                740 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)  (in swift) + 2082  [0x1077d84a2]
                  740 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*)  (in swift) + 561  [0x1077bb9a1]
                    740 swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc)  (in swift) + 5456  [0x1077b3840]
                      740 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&)  (in swift) + 129  [0x1077b3d41]
                        740 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*)  (in swift) + 23795  [0x1077b9a93]
                          740 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::Stmt>(swift::Stmt*&)  (in swift) + 129  [0x1077ba001]
                            740 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*)  (in swift) + 20678  [0x1077b8e66]
                              740 swift::TypeChecker::typeCheckExpressionImpl(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener&, swift::constraints::ConstraintSystem*)  (in swift) + 1042  [0x1077075c2]
                                740 swift::constraints::ConstraintSystem::solve(swift::Expr*&, swift::Type, swift::ExprTypeCheckListener*, llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::FreeTypeVariableBinding)  (in swift) + 9291  [0x10760e77b]
                                  740 swift::constraints::ConstraintSystem::salvage(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::Expr*)  (in swift) + 301  [0x107672fed]
                                    740 swift::constraints::ConstraintSystem::solve(llvm::SmallVectorImpl<swift::constraints::Solution>&)  (in swift) + 238  [0x107609e4e]

@swift-ci create

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

No branches or pull requests

3 participants