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-14271] local lazy var crashed compiler #56631

Closed
swift-ci opened this issue Feb 24, 2021 · 3 comments
Closed

[SR-14271] local lazy var crashed compiler #56631

swift-ci opened this issue Feb 24, 2021 · 3 comments
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-14271
Radar rdar://problem/74747109
Original Reporter maustinstar (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: b762400133f7ae48bba5a1c284cc31bf

Issue Description:

A local lazy var is not allowed, but it is now crashing the compiler.

This crash is happening on main, but not in the current release.

func foo() {
  lazy var a: Int = {
    return 0
  }()
}

The current release version emits the error: `lazy is only valid for members of a struct or class`

Seems to be somewhere in the TypeCheck.
Stack dump:

Stack dump:
0.  Program arguments: /Users/michaelverges/swift-project/build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64/bin/swift-frontend -frontend -c -primary-file /Users/michaelverges/Github/swift-test/test.swift -target x86_64-apple-darwin20.2.0 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -color-diagnostics -target-sdk-version 11.0 -module-name test -o /var/folders/4l/nx9nywmn0dg4pjrlg58b60vw0000gn/T/test-96042c.o
1.  Swift version 5.4-dev (LLVM 39093978579f478, Swift 26aa91e6601a754)
2.  While evaluating request TypeCheckSourceFileRequest(source_file "/Users/michaelverges/Github/swift-test/test.swift")
3.  While evaluating request TypeCheckFunctionBodyRequest(test.(file).foo(x:)@/Users/michaelverges/Github/swift-test/test.swift:2:6)
4.  While walking into initializer for declaration 0x7fd4108490b8 (at /Users/michaelverges/Github/swift-test/test.swift:3:8)
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  swift-frontend           0x00000001108e8a57 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1  swift-frontend           0x00000001108e7b25 llvm::sys::RunSignalHandlers() + 85
2  swift-frontend           0x00000001108e9086 SignalHandler(int) + 262
3  libsystem_platform.dylib 0x00007fff20390d7d _sigtramp + 29
4  swift-frontend           0x0000000113d58445 cmark_strbuf__initbuf + 226000
5  libsystem_c.dylib        0x00007fff2029f720 abort + 120
6  libsystem_c.dylib        0x00007fff2029e9d6 err + 0
7  swift-frontend           0x0000000110f1e3b3 (anonymous namespace)::ContextualizeClosures::walkToExprPre(swift::Expr*) (.cold.5) + 35
8  swift-frontend           0x000000010c8de755 (anonymous namespace)::ContextualizeClosures::walkToExprPre(swift::Expr*) + 741
9  swift-frontend           0x000000010cabd914 (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 36
10 swift-frontend           0x000000010cac00e1 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Decl*) + 2337
11 swift-frontend           0x000000010cabb4b7 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 215
12 swift-frontend           0x000000010cabdd2a swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 458
13 swift-frontend           0x000000010cabafd7 swift::Stmt::walk(swift::ASTWalker&) + 87
14 swift-frontend           0x000000010c8dd1a4 swift::TypeCheckFunctionBodyRequest::evaluate(swift::Evaluator&, swift::AbstractFunctionDecl*) const + 1012
15 swift-frontend           0x000000010cbabd7e llvm::Expected<swift::TypeCheckFunctionBodyRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckFunctionBodyRequest>(swift::TypeCheckFunctionBodyRequest const&) + 414
16 swift-frontend           0x000000010cbabb1b llvm::Expected<swift::TypeCheckFunctionBodyRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckFunctionBodyRequest, (void*)0>(swift::TypeCheckFunctionBodyRequest const&) + 107
17 swift-frontend           0x000000010cb1ae35 swift::TypeCheckFunctionBodyRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyRequest, swift::TypeCheckFunctionBodyRequest::OutputType) + 37
18 swift-frontend           0x000000010c9106ce swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 366
19 swift-frontend           0x000000010c9117ff llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) + 415
20 swift-frontend           0x000000010c9115b4 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckSourceFileRequest, (void*)0>(swift::TypeCheckSourceFileRequest const&) + 100
21 swift-frontend           0x000000010c910480 swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType) + 32
22 swift-frontend           0x000000010bb89b0a swift::CompilerInstance::forEachFileToTypeCheck(llvm::function_ref<void (swift::SourceFile&)>) + 90
23 swift-frontend           0x000000010bb899fa swift::CompilerInstance::performSema() + 74
24 swift-frontend           0x000000010ba1caf5 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4757
25 swift-frontend           0x000000010b9b3907 main + 519
26 libdyld.dylib            0x00007fff20367621 start + 1
<unknown>:0: error: unable to execute command: Abort trap: 6
<unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)
@typesanitizer
Copy link

@swift-ci create

@slavapestov
Copy link
Member

This is supposed to work now, but I didn't test with a nested closure.

@slavapestov
Copy link
Member

#36325

@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