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-7426] Segmentation fault when building with -Osize #49969

Open
ChristopherRogers opened this issue Apr 13, 2018 · 4 comments
Open

[SR-7426] Segmentation fault when building with -Osize #49969

ChristopherRogers opened this issue Apr 13, 2018 · 4 comments
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 optimized only Flag: An issue whose reproduction requires optimized compilation

Comments

@ChristopherRogers
Copy link
Contributor

Previous ID SR-7426
Radar rdar://problem/39414272
Original Reporter @ChristopherRogers
Type Bug
Environment

Xcode 9.3, Swift 4.1

Swift 4.2 master (5ea4848)

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

md5: 9dfe97cde2c14b3c4990b74e565d74af

Issue Description:

Compiling the code below with -Osize should trigger a segfault (or assertion failure). It can be worked around by forcing the type of "resource" to be Optional.

I tried to dig in to the code for this. As far as I could see the error occurs in the Outliner pass in -Osize, where ti's is creating an outline for the Obj-C method call for bundle.path(forResource:ofType🙂. Both of its parameters take Optional<String> (or Optional<NSString>) but it generates a non-optional String parameter type and it causes a type mismatch.

import Foundation

func foo() -> String? {
    let bundle = Bundle.main
    let resource = "common parameter" // add "as String?" for workaround

    return bundle.path(forResource: resource, ofType: "png")
        ?? bundle.path(forResource: resource, ofType: "apng")
}

print(foo() ?? "nope")
@belkadan
Copy link
Contributor

aschwaighofer@apple.com (JIRA User), is this a dup?

@aschwaighofer
Copy link
Member

@swift-ci create

@aschwaighofer
Copy link
Member

Fails on master

@aschwaighofer
Copy link
Member

#15920

@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
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 optimized only Flag: An issue whose reproduction requires optimized compilation
Projects
None yet
Development

No branches or pull requests

4 participants