swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.28k stars 10.33k forks source link

[SR-15095] Internal compiler error with propertyWrapper #57421

Open swift-ci opened 3 years ago

swift-ci commented 3 years ago
Previous ID SR-15095
Radar None
Original Reporter ayxan (JIRA User)
Type Bug
Environment x86-64 swift 5.4 on Linux.
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 2854f5b380f9b4402f05ccd9940475c9

Issue Description:

Internal compiler error is generated when trying to use propertyWrapper. See this godbolt link for the code and more information.

Code:

@propertyWrapper 
struct TwelveOrLess {
  private var number = 0;

  var wrappedValue : Int {
    get { number; }
    set { number = min(newValue, 2); }
  }
}

func main() {
  @TwelveOrLess var i: Int;
}

Compiler output:

Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:

  1. Program arguments: /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend -frontend -S -primary-file \<source> -target x86_64-unknown-linux-gnu -disable-objc-interop -g -enable-anonymous-context-mangled-names -Xllvm --x86-asm-syntax=intel -module-name output -o /app/output.s
  2. Swift version 5.4 (swift-5.4-RELEASE)
  3. While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "\<source>")
  4. While silgen emitFunction SIL function "@$s6output4mainyyF".
    for 'main()' (at \<source>:11:1)
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x5696c44]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x5694ac0]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x5696e2a]
    /lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0)[0x7f73d71303c0]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0xa11e14]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0xa1941d]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x1a75f4f]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0xa1278b]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0xaaacb2]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0xaaaa4d]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0xa53081]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x9d737d]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x9d9836]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x9d5919]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x9dc56f]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0xaaa363]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x9e1854]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x9ddd04]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x539e13]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x52e445]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x4b8d98]
    /lib/x8664-linux-gnu/libc.so.6(\_libc_start_main+0xf3)[0x7f73d6b9e0b3]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x4b8869]
    ASM generation compiler returned: 139
    Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
    Stack dump:
  5. Program arguments: /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend -frontend -c -primary-file \<source> -emit-module-path /tmp/example-ca6d37.swiftmodule -emit-module-doc-path /tmp/example-ca6d37.swiftdoc -emit-module-source-info-path /tmp/example-ca6d37.swiftsourceinfo -target x86_64-unknown-linux-gnu -disable-objc-interop -g -enable-anonymous-context-mangled-names -module-name output -o /tmp/example-ca6d37.o
  6. Swift version 5.4 (swift-5.4-RELEASE)
  7. While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "\<source>")
  8. While silgen emitFunction SIL function "@$s6output4mainyyF".
    for 'main()' (at \<source>:11:1)
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x5696c44]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x5694ac0]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x5696e2a]
    /lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0)[0x7fd029c7d3c0]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0xa11e14]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0xa1941d]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x1a75f4f]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0xa1278b]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0xaaacb2]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0xaaaa4d]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0xa53081]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x9d737d]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x9d9836]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x9d5919]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x9dc56f]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0xaaa363]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x9e1854]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x9ddd04]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x539e13]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x52e445]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x4b8d98]
    /lib/x8664-linux-gnu/libc.so.6(\_libc_start_main+0xf3)[0x7fd0296eb0b3]
    /opt/compiler-explorer/swift-5.4/usr/bin/swift-frontend[0x4b8869]
    \<unknown>:0: error: unable to execute command: Segmentation fault
    \<unknown>:0: error: compile command failed due to signal 11 (use -v to see invocation)
    Execution build compiler returned: 254
typesanitizer commented 3 years ago

I see you're using Swift 5.4 on Linux; is this an issue with a newer compiler too (you can try using a trunk development snapshot from swift.org)? I don't see this issue with newer compilers on macOS, so it could be that this is fixed in newer compilers or that it is Linux-specific.