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-2511] Compiler crash with incorrect checksum for freed object #45116

Closed
iby opened this issue Aug 28, 2016 · 10 comments
Closed

[SR-2511] Compiler crash with incorrect checksum for freed object #45116

iby opened this issue Aug 28, 2016 · 10 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

Comments

@iby
Copy link

iby commented Aug 28, 2016

Previous ID SR-2511
Radar rdar://problem/35702809
Original Reporter @iby
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, ClangImporter, CompilerCrash
Assignee @belkadan
Priority Medium

md5: 1edcf9b21eab4d78989b8b27999411b4

is duplicated by:

  • SR-8317 crash when using C struct

Issue Description:

Trying to compile a piece of code that depends on FFmpeg libavfilter in Xcode 7.3.1 and fails with the following lines present:

@iby
Copy link
Author

iby commented Aug 29, 2016

Separated the problematic code, add the following to bridging header and do UnsafeMutablePointer<Foo>.alloc(1) somewhere in Swift.

typedef struct Foo {
    int x;

    enum {
        A = 0, B, C
    } y;

    int z;
} Foo;

This is solidly reproducible when nested enum is surrounded with primitive properties, I've tried int and char. Frankly, when the enum is surrounded with structs the compiler doesn't crash:

typedef struct Bar {
} Bar;

typedef struct Foo {
    struct Bar *x;

    enum {
        A = 0, B, C
    } y;

    struct Bar *z;
} Foo;

When the enum is the last element in the structure the compiler also doesn't crash:

typedef struct Foo {
    int x;

    enum {
        A = 0, B, C
    } y;
} Foo;

Fun times!

@belkadan
Copy link
Contributor

Interesting. Thanks for the reduction!

@swift-ci
Copy link
Collaborator

Comment by Ronak Patel (JIRA)

I just ran into this issue with Xcode 9.1; and ffmpeg 3.4. Any word on when this would be fixed?

@belkadan
Copy link
Contributor

@swift-ci create

@belkadan
Copy link
Contributor

Arnold tracked this one down to us importing the anonymous enum as having an underlying type of Int rather than Int32. We could fix just the storage part, but then you wouldn't be able to write foo.y = A. On the other hand, changing the type of the constants would break existing source. Still, we should do something here.

If you're willing to hack the headers as a workaround, you can either give the enum a name or an explicit underlying type, enum : int, as supported by Objective-C and C++11. If you're worried about breaking C code (reasonable), you can guard it with #if defined(__swift__).

@belkadan
Copy link
Contributor

#13984

@belkadan
Copy link
Contributor

Fixed in master (but unfortunately not the 4.1 branch, since we're trying to be less disruptive there).

@swift-ci
Copy link
Collaborator

Comment by Ronak Patel (JIRA)

Which version of Xcode would have this fix?

@belkadan
Copy link
Contributor

Whichever one gets Swift 5. (Apple policy won't let me say more than that.)

@belkadan
Copy link
Contributor

Update: "whichever one gets Swift 4.2, which hadn't been invented at the time"

@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