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-15223] Swift/LLVM Crash #57545

Closed
swift-ci opened this issue Sep 21, 2021 · 5 comments
Closed

[SR-15223] Swift/LLVM Crash #57545

swift-ci opened this issue Sep 21, 2021 · 5 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-15223
Radar rdar://problem/83411927
Original Reporter ed4online (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment
$ swift --version swift-driver version: 1.26.9 Apple Swift version 5.5 (swiftlang-1300.0.31.1 clang-1300.0.29.1) Target: x86_64-apple-macosx11.0
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee @beccadax
Priority Medium

md5: 46197bfe3129c8df0bf7d51cdfa541ce

Issue Description:

//
$ swift
Welcome to Swift version 5.5-dev.
Type :help for assistance.
  1> class Foo {}
  2> class Test { 
      func makeFoo (_ bool: Bool) -> Foo? { return bool ? Foo() : nil }
      func process (bools: [Bool]) -> [Foo]? { 
        // the `as? [Foo]` was meant to produce `nil` from [nil, Foo()]
        return bools.map { makeFoo(bool:$0) } as? [Foo]
      } 
    } 
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  lldb                     0x0000000109ce80b7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1  lldb                     0x0000000109ce7775 llvm::sys::RunSignalHandlers() + 85
2  lldb                     0x0000000109ce8966 SignalHandler(int) + 278
3  libsystem_platform.dylib 0x00007fff204d4d7d _sigtramp + 29
4  libsystem_platform.dylib 0x00007ff67b3033d8 _sigtramp + 18446744036579665528
5  LLDB                     0x000000010cd41bcc swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 3772
6  LLDB                     0x000000010cd46b4a (anonymous namespace)::StmtEmitter::visitBraceStmt(swift::BraceStmt*) + 250
7  LLDB                     0x000000010cd40d05 swift::Lowering::SILGenFunction::emitStmt(swift::Stmt*) + 21
8  LLDB                     0x000000010cd06779 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 409
9  LLDB                     0x000000010cca3576 swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 6966
10 LLDB                     0x000000010cca4ab0 emitOrDelayFunction(swift::Lowering::SILGenModule&, swift::SILDeclRef, bool) + 352
11 LLDB                     0x000000010cca1a2b swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 107
12 LLDB                     0x000000010cd4fb83 swift::ASTVisitor<(anonymous namespace)::SILGenType, void, void, void, void, void, void>::visit(swift::Decl*) + 115
13 LLDB                     0x000000010cd4d7ac (anonymous namespace)::SILGenType::emitType() + 108
14 LLDB                     0x000000010cd4d739 swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 25
15 LLDB                     0x000000010cca6bc9 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 1913
16 LLDB                     0x000000010cd408d5 swift::SimpleRequest<swift::ASTLoweringRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> > (swift::ASTLoweringDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::ASTLoweringRequest const&, swift::Evaluator&) + 197
17 LLDB                     0x000000010cabfee7 llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::getResultUncached<swift::ASTLoweringRequest>(swift::ASTLoweringRequest const&) + 231
18 LLDB                     0x000000010cca7af7 swift::performASTLowering(swift::FileUnit&, swift::Lowering::TypeConverter&, swift::SILOptions const&) + 103
19 LLDB                     0x000000010c1162a2 lldb_private::SwiftExpressionParser::Parse(lldb_private::DiagnosticManager&, unsigned int, unsigned int) + 5202
20 LLDB                     0x000000010c125f8d lldb_private::SwiftUserExpression::Parse(lldb_private::DiagnosticManager&, lldb_private::ExecutionContext&, lldb_private::ExecutionPolicy, bool, bool) + 1821
21 LLDB                     0x000000010bf50504 lldb_private::UserExpression::Evaluate(lldb_private::ExecutionContext&, lldb_private::EvaluateExpressionOptions const&, llvm::StringRef, llvm::StringRef, std::__1::shared_ptr<lldb_private::ValueObject>&, lldb_private::Status&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, lldb_private::ValueObject*) + 2260
22 LLDB                     0x000000010bf4e291 lldb_private::REPL::IOHandlerInputComplete(lldb_private::IOHandler&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) + 2721
23 LLDB                     0x000000010bebfcd2 lldb_private::IOHandlerEditline::Run() + 322
24 LLDB                     0x000000010bea5e0f lldb_private::Debugger::RunIOHandlers() + 143
25 LLDB                     0x000000010bea8a43 lldb_private::Debugger::IOHandlerThread(void*) + 19
26 LLDB                     0x000000010bf59177 lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*) + 103
27 libsystem_pthread.dylib  0x00007fff2048f8fc _pthread_start + 224
28 libsystem_pthread.dylib  0x00007fff2048b443 thread_start + 15
Segmentation fault: 11
@swift-ci
Copy link
Collaborator Author

Comment by Ed (JIRA)

The use of `as? [Foo]` or `as! [Foo]` produces the crash. Using `as` or leaving out the clause altogether produces a compiler error (as expected based on the type mismatch).

@typesanitizer
Copy link

@swift-ci create

@swift-ci
Copy link
Collaborator Author

Comment by Ed (JIRA)

$ swift 
Welcome to Swift version 5.5-dev. 
Type :help for assistance.   
1> class Foo {}
2> let foos: [Foo?] = [nil, Foo(), Foo()]  
foos: [Foo?] = 3 values {   
[0] = nil   
[1] = 0x0000000100504300   
[2] = 0x0000000100504a80 
}   
3> let foosCompacted: [Foo]? = foos as? [Foo]  
foosCompacted: [Foo]? = nil

This is as expected.

@beccadax
Copy link
Contributor

beccadax commented Oct 1, 2021

With the compiler I've been working on locally (built recently from main), I get:

<stdin>:6:35: error: extraneous argument label 'bool:' in call
        return bools.map { makeFoo(bool:$0) } as? [Foo]
                                  ^~~~~~

ed4online (JIRA User), can you download the latest "Trunk Development (main)" snapshot from https://swift.org/download/ and see if the bug is fixed for you?

@swift-ci
Copy link
Collaborator Author

swift-ci commented Oct 2, 2021

Comment by Ed (JIRA)

And if you fix the syntax error? [To ensure that my cut-and-paste error when creating this Issue isn't masking the `as?` issue]

On 5.5-dev it is the combination of the syntax error AND `as?` causing the crash. Fix the syntax error or replace `as?` with `as` and the crash goes away.

@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. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

3 participants