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-15200] Returning eventLoop.future<T?, U?>(nil, nil) from ELF.flatMap(_:) causes memory lifetime verifier failure #57522

Closed
gwynne opened this issue Sep 16, 2021 · 5 comments
Assignees
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

Comments

@gwynne
Copy link
Contributor

gwynne commented Sep 16, 2021

Previous ID SR-15200
Radar rdar://problem/83190880
Original Reporter @gwynne
Type Bug
Status Resolved
Resolution Done
Environment
Swift version 5.5-dev (LLVM 27ee1ffec3b6967, Swift c7dd41bf2c475d0)
Target: x86_64-unknown-linux-gnu
Linux ubuntu 5.11.0-1016-aws #&#8203;17~20.04.1-Ubuntu SMP Thu Aug 12 05:39:36 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee @eeckstein
Priority Medium

md5: ce5a1a391a7f060cb7e032d966aaa304

Issue Description:

Partial redacted compiler output:

SIL memory lifetime failure in @$s3App13FooControllerV9createFoo3req7NIOCore15EventLoopFutureCy8NIOHTTP118HTTPResponseStatusOG5Vapor7RequestC_tKFAHyAA20ModelAAExternalInputCSg_AA012ModelBBBBBBBrS0CSgtGAUcfU5_: memory is initialized, but shouldn't
memory location:   %26 = alloc_stack $(Optional<ModelBBBBBBBExternalInput>, Optional<ModelAAExternalInput>) // users: %40, %39, %27
at instruction:   dealloc_stack %26 : $*(Optional<ModelBBBBBBBExternalInput>, Optional<ModelAAExternalInput>) // id: %40
<snip>
1.  Swift version 5.5-dev (LLVM 27ee1ffec3b6967, Swift c7dd41bf2c475d0)
2.
3.  Contents of /tmp/TemporaryDirectory.5Hlpso/sources-1:
<snip>
4.  While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "/home/ubuntu/foo/Sources/App/Controllers/FooController.swift")
@ktoso
Copy link
Member

ktoso commented Sep 16, 2021

@swift-ci create

@typesanitizer
Copy link

Gwynne, could you share a code example?

@eeckstein
Copy link
Member

theindigamer (JIRA User) I talked with Gwynne offline. I don't need a test case. I already know what the problem is

@gwynne
Copy link
Contributor Author

gwynne commented Sep 16, 2021

theindigamer (JIRA User) For what it's worth, I wasn't able to find a repro case any smaller than the actual code where I ran into the issue (a huge Vapor-based service with 1500 source files) - far as I could tell it had something to do with this construct:

func blah(_ req: Request) -> EventLoopFuture<...> {
    return doStuffReturningOptional().flatMap { (obj1: ModelA?) -> EventLoopFuture<(ModelA?, ModelB?)> in
        if obj != nil {
            return req.eventLoop.makeSucceededFuture((nil, nil)) // <-- this (nil, nil) tuple is the proximate culprit
        }
        return doSomeStuffReturningAnotherObject().flatMap { obj2 in
            return doSomeMoreStuff().map { (obj1, obj2) }
        }
    }
}

I couldn't figure out a repro despite having it narrowed down this far, but fortunately Erik figured out the problem (whatever it is! 😃) from the details I gave offline.

@eeckstein
Copy link
Member

This is already fixed on main by #38128

@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
Projects
None yet
Development

No branches or pull requests

5 participants