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-4866] Stack overflow: Parsing phony empty paren exprs #47443

Closed
bitjammer opened this issue May 11, 2017 · 2 comments
Closed

[SR-4866] Stack overflow: Parsing phony empty paren exprs #47443

bitjammer opened this issue May 11, 2017 · 2 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 good first issue Good for newcomers parser Area → compiler: The legacy C++ parser

Comments

@bitjammer
Copy link
Member

Previous ID SR-4866
Radar None
Original Reporter @bitjammer
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, Parser, StarterBug
Assignee christopherstern (JIRA)
Priority Medium

md5: 5b7a64ad744a870b56645db75101ffef

Issue Description:

Parse the attached file. Stack overflow.

495 swift 0x0000000106d9e9aa swift::Parser::parseExprList(swift::tok, swift::tok, bool, bool, swift::SourceLoc&, llvm::SmallVectorImpl<swift::Expr*>&, llvm::SmallVectorImpl<swift::Identifier>&, llvm::SmallVectorImpl<swift::SourceLoc>&, swift::SourceLoc&, swift::Expr*&) + 218
496 swift 0x0000000106d9efb1 swift::Parser::parseExprList(swift::tok, swift::tok) + 209
497 swift 0x0000000106d949e0 swift::Parser::parseExprPostfix(swift::Diag<>, bool) + 2416
498 swift 0x0000000106d926b5 swift::Parser::parseExprSequence(swift::Diag<>, bool, bool) + 3717
499 swift 0x0000000106d91795 swift::Parser::parseExprImpl(swift::Diag<>, bool) + 101
500 swift 0x0000000106da0be1 std::**1::function::func<swift::Parser::parseExprList(swift::tok, swift::tok, bool, bool, swift::SourceLoc&, llvm::SmallVectorImpl<swift::Expr*>&, llvm::SmallVectorImpl<swift::Identifier>&, llvm::SmallVectorImpl<swift::SourceLoc>&, swift::SourceLoc&, swift::Expr*&)::$2, std::_1::allocator<swift::Parser::parseExprList(swift::tok, swift::tok, bool, bool, swift::SourceLoc&, llvm::SmallVectorImpl<swift::Expr*>&, llvm::SmallVectorImpl<swift::Identifier>&, llvm::SmallVectorImpl<swift::SourceLoc>&, swift::SourceLoc&, swift::Expr*&)::$_2>, swift::ParserStatus ()>::operator()() + 113
501 swift 0x0000000106dafa6c swift::Parser::parseList(swift::tok, swift::SourceLoc, swift::SourceLoc&, bool, swift::Diag<>, std::_1::function<swift::ParserStatus ()>) + 396
502 swift 0x0000000106d9e9aa swift::Parser::parseExprList(swift::tok, swift::tok, bool, bool, swift::SourceLoc&, llvm::SmallVectorImpl<swift::Expr*>&, llvm::SmallVectorImpl<swift::Identifier>&, llvm::SmallVectorImpl<swift::SourceLoc>&, swift::SourceLoc&, swift::Expr*&) + 218
503 swift 0x0000000106d9efb1 swift::Parser::parseExprList(swift::tok, swift::tok) + 209
504 swift 0x0000000106d949e0 swift::Parser::parseExprPostfix(swift::Diag<>, bool) + 2416
505 swift 0x0000000106d926b5 swift::Parser::parseExprSequence(swift::Diag<>, bool, bool) + 3717
506 swift 0x0000000106d91795 swift::Parser::parseExprImpl(swift::Diag<>, bool) + 101
507 swift 0x0000000106da0be1 std::1::function::func<swift::Parser::parseExprList(swift::tok, swift::tok, bool, bool, swift::SourceLoc&, llvm::SmallVectorImpl<swift::Expr*>&, llvm::SmallVectorImpl<swift::Identifier>&, llvm::SmallVectorImpl<swift::SourceLoc>&, swift::SourceLoc&, swift::Expr*&)::$2, std::_1::allocator<swift::Parser::parseExprList(swift::tok, swift::tok, bool, bool, swift::SourceLoc&, llvm::SmallVectorImpl<swift::Expr*>&, llvm::SmallVectorImpl<swift::Identifier>&, llvm::SmallVectorImpl<swift::SourceLoc>&, swift::SourceLoc&, swift::Expr*&)::$_2>, swift::ParserStatus ()>::operator()() + 113
508 swift 0x0000000106dafa6c swift::Parser::parseList(swift::tok, swift::SourceLoc, swift::SourceLoc&, bool, swift::Diag<>, std::
_1::function<swift::ParserStatus ()>) + 396
509 swift 0x0000000106d9e9aa swift::Parser::parseExprList(swift::tok, swift::tok, bool, bool, swift::SourceLoc&, llvm::SmallVectorImpl<swift::Expr*>&, llvm::SmallVectorImpl<swift::Identifier>&, llvm::SmallVectorImpl<swift::SourceLoc>&, swift::SourceLoc&, swift::Expr*&) + 218
510 swift 0x0000000106d9efb1 swift::Parser::parseExprList(swift::tok, swift::tok) + 209
511 swift 0x0000000106d949e0 swift::Parser::parseExprPostfix(swift::Diag<>, bool) + 2416

etc.

@swift-ci
Copy link
Collaborator

swift-ci commented Oct 1, 2018

Comment by Christopher Ian Stern (JIRA)

Apple Swift version 4.2 (swiftlang-1000.11.37.1 clang-1000.11.45.1) crashes on the provided file `t.swift` without a much of a diagnostic

{{ $ swiftc t.swift}}

{{ <unknown>:0: error: unable to execute command: Illegal instruction: 4}}
{{ <unknown>:0: error: compile command failed due to signal 4 (use -v to see invocation)}}

The file is rather silly though swift is being rather unhelpful here.

The same stack overflow happens in a simpler case, with just a large number of parens that is

let x = ((((((((...

if you use enough parens.

manyparen.swift

@swift-ci
Copy link
Collaborator

Comment by Christopher Ian Stern (JIRA)

This was fixed by PR-19631, merged into master on Oct 9.

The file t.swift is now in the tests as file swift/test/Parse/structure_overflow_paren_exprs.swift

Resolving

@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 good first issue Good for newcomers parser Area → compiler: The legacy C++ parser
Projects
None yet
Development

No branches or pull requests

3 participants