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-5153] Miscompile in Swift 3.2 results in zombie message (regression from 3.1) #4089

Closed
swift-ci opened this issue Jun 7, 2017 · 4 comments

Comments

@swift-ci
Copy link
Contributor

swift-ci commented Jun 7, 2017

Previous ID SR-5153
Radar rdar://problem/32625475
Original Reporter benasher44 (JIRA User)
Type Bug
Status Closed
Resolution Cannot Reproduce
Environment

macOS Sierra 10.12.5
Xcode 9 beta 1
Swift 3.2/4

Additional Detail from JIRA
Votes 0
Component/s Compiler, Foundation
Labels Bug, 4.0Regression, RunTimeCrash
Assignee None
Priority Medium

md5: 662f5f52aa64a4841c2845dda9fc7d09

Issue Description:

Consider the following code, which runs error-free in Swift 3.1, but results in a runtime crash in Swift 3.2 and Swift 4:

import Foundation

struct S {
  var str = UUID().uuidString
}

func go() {
    var s = S()
    s = S()

    _ = DispatchQueue.global(qos: .default).async {
        print(s.str)
    }
}

go()
sleep(1)

This crashes using swift that ships with Xcode 9 beta 1 by running it in the following ways:
swift -swift-version 3 file.swift
swift file.swift

Output from the program:

0CC3D5F2-3F86-4B6E-88B6-181891DEF66C
0 swift 0x00000001110823aa PrintStackTraceSignalHandler(void*) + 42
1 swift 0x00000001110817e6 SignalHandler(int) + 662
2 libsystem_platform.dylib 0x00007fffb6d64b3a _sigtramp + 26
3 libsystem_platform.dylib 000000000000000000 _sigtramp + 1227470048
4 libsystem_platform.dylib 0x0000000113ad1744 _sigtramp + 1557580836
5 libswiftCore.dylib 0x00000001167a6770 _swift_release_dealloc + 16
6 libswiftCore.dylib 0x0000000113ad1894 _swift_release_dealloc + 4247957812
7 libsystem_blocks.dylib 0x00007fffb6b89952 _Block_release + 102
8 libdispatch.dylib 0x00007fffb6b1f8fc _dispatch_client_callout + 8
9 libdispatch.dylib 0x00007fffb6b2e196 _dispatch_queue_override_invoke + 743
10 libdispatch.dylib 0x00007fffb6b216b5 _dispatch_root_queue_drain + 476
11 libdispatch.dylib 0x00007fffb6b2148c _dispatch_worker_thread3 + 99
12 libsystem_pthread.dylib 0x00007fffb6d6e5a2 _pthread_wqthread + 1299
13 libsystem_pthread.dylib 0x00007fffb6d6e07d start_wqthread + 13
Killed: 9

In Instruments, you can see that the string held by s is released an extra time.

@swift-ci
Copy link
Contributor Author

swift-ci commented Jun 7, 2017

Comment by Ben A (JIRA)

Ben-G (JIRA User) spoke with @jckarter about this one at the lab today.

@belkadan
Copy link

belkadan commented Jun 7, 2017

@swift-ci create

@swift-ci
Copy link
Contributor Author

swift-ci commented Aug 2, 2017

Comment by Matt Rajca (JIRA)

Looks fixed in (swiftlang-900.0.58 clang-900.0.33).

@belkadan
Copy link

Yep, this was
master: apple/swift#10278
4.0: apple/swift#10283

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants