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-13878] Simple program crashes on exit possibly due to disorderly teardown (v5.3) #56276

swift-ci opened this issue Nov 19, 2020 · 2 comments


Copy link

@swift-ci swift-ci commented Nov 19, 2020

Previous ID SR-13878
Radar rdar://problem/71589860
Original Reporter awal (JIRA User)
Type Bug


Additional Detail from JIRA
Votes 0
Labels Bug, RunTimeCrash
Assignee None
Priority Medium

md5: 632ca2b1f3a11eb0fbba76200cb815ef

Issue Description:

Running the program at bottom sometimes prints:


Occasionally, it prints:

hello BlockExperiment world

However, the following crash consistently reproduces on a Mac and Linux machine:

 hello BlockExperiment/usr/bin/swift[0x51f95a4]

(I thought there might be a race condition in my code, so I asked about it on StackOverflow:

To reproduce, run this script:

import Foundation

final class BlockRunner {
  var block: () -> ()
  init(_ b: @escaping () -> ()) { block = b }
  func run() { block() }
  deinit { print("Deinit: \(self)") }

final class BlockExperiment {
  func f() { 
    let queue = DispatchQueue(label: "Queue")
    let runner = BlockRunner { print("hello", self, "world") }
    queue.asyncAfter(deadline: .now() + 1) { }
  deinit { print("Deinit: \(self)") }

do {
  let e = BlockExperiment()
  e.f() Date() + 1 + 0.000000000000001)
Copy link

@typesanitizer typesanitizer commented Nov 19, 2020

@swift-ci create

Copy link

@eeckstein eeckstein commented Nov 23, 2020

The indeterministic output is easily explainable.

Though, I could not reproduce the crash (on Mac).
Could you reproduce the crash on Mac?

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

No branches or pull requests

3 participants