Shouldn't ThreadSanitizer catch this?

I'm trying to make an example to show using the thread sanitizer and so I used this code.


final class MainViewController: UIViewController {
  var counter = 0
  
  override func viewDidLoad() {
    super.viewDidLoad()

    let queue = DispatchQueue(label: "q", qos: .background)
    queue.async {
      for _ in 1 ... 10000 {
        self.counter += 1
      }
    }

    DispatchQueue.main.async {
      for _ in 1 ... 10000 {
        self.counter += 1
      }
    }
  }
}


It doesn't have any issues with it. However, if I change the counter variable like so:


  var counter = 0 {
    didSet {
      print(#line, counter)
    }
  }


And then run it, then it aborts. It's also critical for the #line there. Without, it doesn't fail. I'm completely confused on why the print with the line number triggers the read/write across threads but without it thread sanitizer has no issues.