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

crash on _read that yields a local binding #71598

Closed
tayloraswift opened this issue Feb 14, 2024 · 3 comments · Fixed by #71630
Closed

crash on _read that yields a local binding #71598

tayloraswift opened this issue Feb 14, 2024 · 3 comments · Fixed by #71630
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels

Comments

@tayloraswift
Copy link
Contributor

Description

this crashes the 5.10 compiler

Reproduction

var last:String
{
    _read
    {
        let x:String = ""
        yield x
    }
}

Stack dump

error: compile command failed due to signal 6 (use -v to see invocation)
swift-frontend: /home/ec2-user/swift/lib/SILGen/SILGenLValue.cpp:3332: void swift::Lowering::LValue::addNonMemberVarComponent(SILGenFunction &, SILLocation, VarDecl *, SubstitutionMap, LValueOptions, SGFAccessKind, AccessStrategy, CanType, llvm::Optional<ActorIsolation>)::NonMemberVarAccessEmitter::emitUsingStorage(LValueTypeData): Assertion `address.isLValue() && "Must have a physical copyable lvalue decl ref that " "evaluates to an address"' failed.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.      Program arguments: /usr/bin/swift-frontend -frontend -c -primary-file crash5.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -color-diagnostics -new-driver-path /usr/bin/swift-driver -empty-abi-descriptor -resource-dir /usr/lib/swift -module-name crash5 -plugin-path /usr/lib/swift/host/plugins -plugin-path /usr/local/lib/swift/host/plugins -o /tmp/TemporaryDirectory.5OuXDQ/crash5-1.o
1.      Swift version 5.10-dev (LLVM dbfaba0078e9380, Swift 63c8b551eb2f613)
2.      Compiling with the current language version
3.      While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "crash5.swift")
4.      While silgen emitFunction SIL function "@$s6crash54lastSSvr".
 for read for last (at crash5.swift:1:5)
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):
/usr/bin/swift-frontend(+0x72e33f4)[0x55f1f34993f4]
/usr/bin/swift-frontend(+0x72e10ce)[0x55f1f34970ce]
/usr/bin/swift-frontend(+0x72e3768)[0x55f1f3499768]
/lib64/libc.so.6(+0x54dd0)[0x7f14760a1dd0]
/lib64/libc.so.6(+0xa153c)[0x7f14760ee53c]
/lib64/libc.so.6(raise+0x16)[0x7f14760a1d26]
/lib64/libc.so.6(abort+0xd3)[0x7f14760757f3]
/lib64/libc.so.6(+0x2871b)[0x7f147607571b]
/lib64/libc.so.6(+0x4dcc6)[0x7f147609acc6]
/usr/bin/swift-frontend(+0x158316b)[0x55f1ed73916b]
/usr/bin/swift-frontend(+0x15843e2)[0x55f1ed73a3e2]
/usr/bin/swift-frontend(+0x1584f29)[0x55f1ed73af29]
/usr/bin/swift-frontend(+0x1580be2)[0x55f1ed736be2]
/usr/bin/swift-frontend(+0x158091f)[0x55f1ed73691f]
/usr/bin/swift-frontend(+0x1628822)[0x55f1ed7de822]
/usr/bin/swift-frontend(+0x1624b3f)[0x55f1ed7dab3f]
/usr/bin/swift-frontend(+0x16116b9)[0x55f1ed7c76b9]
/usr/bin/swift-frontend(+0x1611211)[0x55f1ed7c7211]
/usr/bin/swift-frontend(+0x15d800c)[0x55f1ed78e00c]
/usr/bin/swift-frontend(+0x15d9427)[0x55f1ed78f427]
/usr/bin/swift-frontend(+0x15d7c9d)[0x55f1ed78dc9d]
/usr/bin/swift-frontend(+0x156d9db)[0x55f1ed7239db]
/usr/bin/swift-frontend(+0x14f3c9e)[0x55f1ed6a9c9e]
/usr/bin/swift-frontend(+0x14f4cff)[0x55f1ed6aacff]
/usr/bin/swift-frontend(+0x14f2325)[0x55f1ed6a8325]
/usr/bin/swift-frontend(+0x27f619a)[0x55f1ee9ac19a]
/usr/bin/swift-frontend(+0x14f2153)[0x55f1ed6a8153]
/usr/bin/swift-frontend(+0x14f7f97)[0x55f1ed6adf97]
/usr/bin/swift-frontend(+0x15d75bb)[0x55f1ed78d5bb]
/usr/bin/swift-frontend(+0x14fb1e3)[0x55f1ed6b11e3]
/usr/bin/swift-frontend(+0x14f8db8)[0x55f1ed6aedb8]
/usr/bin/swift-frontend(+0xe122c6)[0x55f1ecfc82c6]
/usr/bin/swift-frontend(+0xe284aa)[0x55f1ecfde4aa]
/usr/bin/swift-frontend(+0xe15dcb)[0x55f1ecfcbdcb]
/usr/bin/swift-frontend(+0xe14533)[0x55f1ecfca533]
/usr/bin/swift-frontend(+0xcc2da3)[0x55f1ece78da3]
/lib64/libc.so.6(+0x3feb0)[0x7f147608ceb0]
/lib64/libc.so.6(__libc_start_main+0x80)[0x7f147608cf60]
/usr/bin/swift-frontend(+0xcc1d85)[0x55f1ece77d85]
error: fatalError

Expected behavior

it compiles fine in 5.9

Environment

Swift version 5.10-dev (LLVM dbfaba0078e9380, Swift 63c8b55)
Target: x86_64-unknown-linux-gnu

Additional information

it also crashes the 5.10 compiler on SwiftFiddle

@tayloraswift tayloraswift added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels labels Feb 14, 2024
@tayloraswift
Copy link
Contributor Author

it also crashes on main

jckarter added a commit to jckarter/swift that referenced this issue Feb 15, 2024
Replace the "must be an address" assertion with an implementation
that emits and borrows the base value. Fixes apple#71598.
@jckarter
Copy link
Member

#71630 should fix it. You mentioned in https://forums.swift.org/t/pitch-piecewise-consumption-of-noncopyable-values/70045/4 that you were also seeing this problem with _modify coroutines, but those would not be affected by this same code path, and I wasn't able to reproduce a crash with a similar _modify coroutine yourself. Do you have an example of the crash you're seeing with a _modify coroutine?

@tayloraswift
Copy link
Contributor Author

i don’t recall seeing this specifically with _modifys, only in the vicinity of yields on local bindings, and i extrapolated from that to all uses of yield. i was also not able to produce a crash in _modify by fuzzing the test program, but i don’t know yet if there are no such instances in our code base, because we do have a number of _modifys that yield local bindings and i am still working on getting the projects to build again due to other 5.10 compiler crashes.

in the absence of a specific reproducer, i think it’s reasonable to assume it only affects _reads. thanks for the fix!

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. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants