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-13907] SILGen crashes in emitRValueAsSingleValue #56305

Closed
swift-ci opened this issue Nov 28, 2020 · 3 comments
Closed

[SR-13907] SILGen crashes in emitRValueAsSingleValue #56305

swift-ci opened this issue Nov 28, 2020 · 3 comments
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 SILGen Area → compiler: The SIL generation stage

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-13907
Radar rdar://problem/71913166
Original Reporter jaspa (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Apple Swift version 5.3.1 (swiftlang-1200.0.41 clang-1200.0.32.8)
Target: x86_64-apple-darwin19.6.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, SILGen
Assignee None
Priority Medium

md5: 0458a40d0d104b2bfb3556740322597b

Issue Description:

The attached code crashes during compilation, I tried to reduce it as much as possible.

The full stack trace is attached, but the summary reads

1.  Apple Swift version 5.3.1 (swiftlang-1200.0.41 clang-1200.0.32.8)
2.  While evaluating request SILGenSourceFileRequest(SIL Generation for file "crasher.swift")
3.  While emitting SIL for 'f(_:_:)' (at crasher.swift:17:1)
4.  While silgen emitFunction SIL function "@$s7crasher1fyyx_xtlF".
 for 'f(_:_:)' (at crasher.swift:17:1)
5.  While silgen closureexpr SIL function "@$s7crasher1fyyx_xtlFySRyXeGXEfU_".
 for expression at [crasher.swift:19:46 - line:21:3] RangeText="{ buffer in
    f(array, Array(UnsafeBufferPointer(buffer)))
  "

There are two small changes I discovered which when applied don't lead to a crash:

  1.  func f<T>(_ : T, _ : T) {
       let array = Array<Int>()
    -  S2(array).withContiguousStorageIfAvailable { buffer in
    +  S2<[Int]>(array).withContiguousStorageIfAvailable { buffer in
         f(array, Array(UnsafeBufferPointer(buffer)))
       }
     }
  2.  func f<T>(_ : T, _ : T) {
       let array = Array<Int>()
       S2(array).withContiguousStorageIfAvailable { buffer in
    -    f(array, Array(UnsafeBufferPointer(buffer)))
    +    f(array, Array(buffer))
       }
     }
@typesanitizer
Copy link

@swift-ci create

@xymus
Copy link
Contributor

xymus commented Dec 3, 2020

Thank you for reporting this issue Janek. Luckily it looks like it's already fixed in the top-of-tree Swift compiler main branch. Can you verify what it has the behavior that you would expect? You can download a Trunk Development (main) snapshot from https://swift.org/download/#snapshots to git it a try.

@xymus
Copy link
Contributor

xymus commented Dec 13, 2021

Marking as resolved. Please reopen a but report if you're still seeing this issue.

@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 SILGen Area → compiler: The SIL generation stage
Projects
None yet
Development

No branches or pull requests

4 participants