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-6541] Swift Compiler Fills Memory Until Computer Crashes #49091

Closed
Frizlab opened this issue Dec 5, 2017 · 5 comments
Closed

[SR-6541] Swift Compiler Fills Memory Until Computer Crashes #49091

Frizlab opened this issue Dec 5, 2017 · 5 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

@Frizlab
Copy link

Frizlab commented Dec 5, 2017

Previous ID SR-6541
Radar rdar://problem/35882375
Original Reporter @Frizlab
Type Bug
Status Resolved
Resolution Duplicate
Environment

Xcode 9.2 (9C40b) on macOS Sierra (16G1036)

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

md5: 075ba9221f5127653f12eb99d046ec85

duplicates:

Issue Description:

Try and compile the following Swift source:

print("Hello, World!")

struct Container {let string = "yes"}
let optionalContainer: Container? = Container()
let optionalString: String? = "toto"

switch optionalString {
case optionalContainer?.string?: ()
default: ()
}

The compiler just fills your memory until the computer crashes.

@Frizlab
Copy link
Author

Frizlab commented Dec 5, 2017

Most probably related to SR-6540

@slavapestov
Copy link
Member

BindOptional expression is out of its depth
(bind_optional_expr type='Container' location=cr.swift:6:23 range=[cr.swift:6:6 - line:6:23] depth=0
(declref_expr type='Container?' location=cr.swift:6:6 range=[cr.swift:6:6 - line:6:6] decl=cr.(file).optionalContainer@cr.swift:3:5 direct_to_storage function_ref=unapplied))0  swift                    0x000000010c67cd28 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x000000010c67d3e6 SignalHandler(int) + 470
2  libsystem_platform.dylib 0x00007fff59989f5a _sigtramp + 26
3  swift                    0x000000010d2b6828 (anonymous namespace)::DarwinX86AsmBackend::getCompactUnwindRegNum(unsigned int) const::CU64BitRegs + 222898
4  libsystem_c.dylib        0x00007fff597b532a abort + 127
5  swift                    0x000000010a0af8f3 (anonymous namespace)::Verifier::walkToExprPost(swift::Expr*) + 14563
6  swift                    0x000000010a0be07e swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 1870
7  swift                    0x000000010a0be204 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 2260
8  swift                    0x000000010a0c1963 (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 211
9  swift                    0x000000010a0c1a8b (anonymous namespace)::Traversal::visitSelfApplyExpr(swift::SelfApplyExpr*) + 91
10 swift                    0x000000010a0c18e6 (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 86
11 swift                    0x000000010a0c3157 (anonymous namespace)::Traversal::visit(swift::Pattern*) + 1015
12 swift                    0x000000010a0c30e2 (anonymous namespace)::Traversal::visit(swift::Pattern*) + 898
13 swift                    0x000000010a0c2284 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 1748
14 swift                    0x000000010a0c21a8 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 1528
15 swift                    0x000000010a0c1c90 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 224
16 swift                    0x000000010a0bd355 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 1381
17 swift                    0x000000010a0bcddb swift::Decl::walk(swift::ASTWalker&) + 27
18 swift                    0x000000010a1580ea swift::SourceFile::walk(swift::ASTWalker&) + 170
19 swift                    0x000000010a0ab2eb swift::verify(swift::SourceFile&) + 59
20 swift                    0x0000000109e9204f swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int) + 1999
21 swift                    0x0000000109b1e533 swift::CompilerInstance::parseAndTypeCheckMainFile(swift::PersistentParserState&, swift::DelayedParsingCallbacks*, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>) + 435
22 swift                    0x0000000109b1d3ec swift::CompilerInstance::parseAndCheckTypes(swift::CompilerInstance::ImplicitImports const&) + 764
23 swift                    0x0000000109b1cb74 swift::CompilerInstance::performSema() + 532
24 swift                    0x000000010900e1c5 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1781
25 swift                    0x000000010900cb0a swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3210
26 swift                    0x0000000108fcd9b0 main + 3360
27 libdyld.dylib            0x00007fff59709145 start + 1

@belkadan
Copy link
Contributor

belkadan commented Dec 6, 2017

Anything that crashes will almost certainly crash the same way when unrelated code is added before it. No need to file a second bug for that.

@Frizlab
Copy link
Author

Frizlab commented Dec 6, 2017

@belkadan Yes of course. The behaviour I got was very different though (one segfaulted; the other did not crash but was leaking many GB of memory per seconds), so I thought it might have been interesting to get both.

@belkadan
Copy link
Contributor

belkadan commented Dec 6, 2017

Yeah, that makes sense. I think we can still track them together in this case.

@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