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

explicit (consume self) crashes compiler when accessing nested property #71600

Open
tayloraswift opened this issue Feb 14, 2024 · 1 comment
Open
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 ownership Feature: Ownership modifiers and semantics

Comments

@tayloraswift
Copy link
Contributor

Description

this crashes the 5.10 compiler

Reproduction

struct E:~Copyable
{
    let r:Range<Int>

    consuming
    func f()
    {
        (consume self).r.upperBound
    }
}

Stack dump

<stdin>:9:26: warning: expression of type 'Int' is unused
        (consume self).r.upperBound
        ~~~~~~~~~~~~~~~~~^~~~~~~~~~
(consume_expr type='E' location=<stdin>:9:10 range=[<stdin>:9:10 - line:9:18]
  (load_expr implicit type='E' location=<stdin>:9:18 range=[<stdin>:9:18 - line:9:18]
    (declref_expr type='@lvalue E' location=<stdin>:9:18 range=[<stdin>:9:18 - line:9:18] decl=main.(file).E.f().self@<stdin>:7:10 function_ref=unapplied)))<unknown>:0: error: fatal error encountered during compilation; please submit a bug report (https://swift.org/contributing/#reporting-bugs)
<unknown>:0: note: Unimplemented node!
Stack dump:
0.      Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -I swiftfiddle.com/_Packages/.build/release -new-driver-path /usr/bin/swift-driver -empty-abi-descriptor -resource-dir /usr/lib/swift -module-name main -plugin-path /usr/lib/swift/host/plugins -plugin-path /usr/local/lib/swift/host/plugins -l_Packages
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 module main)
4.      While silgen emitFunction SIL function "@$s4main1EV1fyyF".
 for 'f()' (at <stdin>:7: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(+0x7307d73)[0x5647539e7d73]
/usr/bin/swift-frontend(+0x7305abe)[0x5647539e5abe]
/usr/bin/swift-frontend(+0x73080ea)[0x5647539e80ea]
/lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x7fc43c13c520]
/lib/x86_64-linux-gnu/libc.so.6(pthread_kill+0x12c)[0x7fc43c1909fc]
/lib/x86_64-linux-gnu/libc.so.6(raise+0x16)[0x7fc43c13c476]
/lib/x86_64-linux-gnu/libc.so.6(abort+0xd3)[0x7fc43c1227f3]
/usr/bin/swift-frontend(+0xe3f95d)[0x56474d51f95d]
/usr/bin/swift-frontend(+0x7227d1b)[0x564753907d1b]
/usr/bin/swift-frontend(+0x7227bf6)[0x564753907bf6]
/usr/bin/swift-frontend(+0x15b7be7)[0x56474dc97be7]
/usr/bin/swift-frontend(+0x15a7586)[0x56474dc87586]
/usr/bin/swift-frontend(+0x15b7918)[0x56474dc97918]
/usr/bin/swift-frontend(+0x15a7522)[0x56474dc87522]
/usr/bin/swift-frontend(+0x15a6d9c)[0x56474dc86d9c]
/usr/bin/swift-frontend(+0x15ac0d0)[0x56474dc8c0d0]
/usr/bin/swift-frontend(+0x15a6254)[0x56474dc86254]
/usr/bin/swift-frontend(+0x15a5f4f)[0x56474dc85f4f]
/usr/bin/swift-frontend(+0x15772e1)[0x56474dc572e1]
/usr/bin/swift-frontend(+0x15727af)[0x56474dc527af]
/usr/bin/swift-frontend(+0x1567451)[0x56474dc47451]
/usr/bin/swift-frontend(+0x15fe6cb)[0x56474dcde6cb]
/usr/bin/swift-frontend(+0x15fd15d)[0x56474dcdd15d]
/usr/bin/swift-frontend(+0x1592d99)[0x56474dc72d99]
/usr/bin/swift-frontend(+0x151827d)[0x56474dbf827d]
/usr/bin/swift-frontend(+0x151931c)[0x56474dbf931c]
/usr/bin/swift-frontend(+0x15166f4)[0x56474dbf66f4]
/usr/bin/swift-frontend(+0x1612c92)[0x56474dcf2c92]
/usr/bin/swift-frontend(+0x160eef4)[0x56474dceeef4]
/usr/bin/swift-frontend(+0x160ec08)[0x56474dceec08]
/usr/bin/swift-frontend(+0x151c5c7)[0x56474dbfc5c7]
/usr/bin/swift-frontend(+0x15fca8c)[0x56474dcdca8c]
/usr/bin/swift-frontend(+0x151f8df)[0x56474dbff8df]
/usr/bin/swift-frontend(+0x151cfdf)[0x56474dbfcfdf]
/usr/bin/swift-frontend(+0xe34965)[0x56474d514965]
/usr/bin/swift-frontend(+0xe4a7f5)[0x56474d52a7f5]
/usr/bin/swift-frontend(+0xe382ad)[0x56474d5182ad]
/usr/bin/swift-frontend(+0xe369db)[0x56474d5169db]
/usr/bin/swift-frontend(+0xcc3315)[0x56474d3a3315]
/lib/x86_64-linux-gnu/libc.so.6(+0x29d90)[0x7fc43c123d90]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80)[0x7fc43c123e40]
/usr/bin/swift-frontend(+0xcc2375)[0x56474d3a2375]
*** Signal 11: Backtracing from 0x7fc43c122898... done ***
*** Program crashed: Bad pointer dereference at 0x0000000000000000 ***
Thread 0 "swift-frontend" crashed:
0  0x00007fc43c122898 <unknown> in libc.so.6
Registers:
rax 0x0000000000000000  0
rdx 0x00007fc43bff9840  40 98 ff 3b c4 7f 00 00 60 a2 ff 3b c4 7f 00 00  @·ÿ;Ä···`¢ÿ;Ä···
rcx 0x00007fc43c1909fc  41 89 c5 41 f7 dd 3d 00 f0 ff ff b8 00 00 00 00  A·ÅA÷Ý=·ðÿÿ¸····
rbx 0x0000000000000006  6
rsi 0x0000000000000001  1
rdi 0x0000000000000001  1
rbp 0x00007fc43c315e90  01 00 00 00 01 00 00 00 40 98 ff 3b c4 7f 00 00  ········@·ÿ;Ä···
rsp 0x00007ffd87103a30  20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ···············
 r8 0x0000000000000000  0
 r9 0x0000000000000000  0
r10 0x0000000000000008  8
r11 0x0000000000000246  582
r12 0x00007ffd87104050  d0 42 10 87 fd 7f 00 00 08 4c 10 87 fd 7f 00 00  ÐB··ý····L··ý···
r13 0x00007ffd87103f10  29 88 1a 55 47 56 00 00 cd 87 ee 4e 47 56 00 00  )··UGV··Í·îNGV··
r14 0x0000000000000001  1
r15 0x0000000000000000  0
rip 0x00007fc43c122898  f4 83 3d 00 36 1f 00 05 75 14 c7 05 f4 35 1f 00  ô·=·6···u·Ç·ô5··
rflags 0x0000000000010246  ZF PF
cs 0x0033  fs 0x0000  gs 0x0000
Images (23 omitted):
0x00007fc43c0fa000–0x00007fc43c2b6341 c289da5071a3399de893d2af81d6a30c62646e1e libc.so.6 /usr/lib/x86_64-linux-gnu/libc.so.6
Backtrace took 0.00s

Expected behavior

it worked in 5.9

Environment

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

Additional information

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 does not crash on main

@hborla hborla added ownership Feature: Ownership modifiers and semantics and removed triage needed This issue needs more specific labels labels Apr 27, 2024
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 ownership Feature: Ownership modifiers and semantics
Projects
None yet
Development

No branches or pull requests

2 participants