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-14176] Swift compiler crashes when a throwing call is used within print #56554

Closed
kasei opened this issue Feb 9, 2021 · 4 comments
Closed
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

@kasei
Copy link
Contributor

kasei commented Feb 9, 2021

Previous ID SR-14176
Radar rdar://problem/74190103
Original Reporter @kasei
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

I see this failing on both the "5.3.3" docker image (which I believe is ubuntu 18.04) and 5.3.2 on MacOS.

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

md5: 70272cc9ce86f932f74ae1bcb10f5e4c

Issue Description:

The use of a throwing function inside of a print string, when in the context of a non-throwing function, seems to cause the compiler to crash:

func nonThrowingFunc() {
    try print("\(throwingFunc())")
}

This results in a segmentation fault in SIL generation (example script and stack trace attached).

@kasei
Copy link
Contributor Author

kasei commented Feb 9, 2021

An interesting related issue is seen by pulling the string out of the print call, and trying to assign it separately:

func nonThrowingFunc() {
    let s = try "\(throwingFunc())"
    print(s)
}

Instead of crashing, this seems to hang. I killed the compiler after 5 minutes of it pegging the CPU core at 100%.

@typesanitizer
Copy link

@swift-ci create

@hborla
Copy link
Member

hborla commented Feb 11, 2021

This was fixed with #35321 which was also cherry-picked to 5.4. Could you please verify in the latest main or 5.4 snapshot from https://swift.org/download/#snapshots ? Thanks!

@kasei
Copy link
Contributor Author

kasei commented Feb 11, 2021

@hborla – Looks good in 5.4-dev. Thank you!

@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

4 participants