[all-commits] [llvm/llvm-project] 2ac0c4: [DirectoryWatcher] Fix misuse of FSEvents API and ...

Ben Langmuir via All-commits all-commits at lists.llvm.org
Tue Feb 11 09:34:23 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 2ac0c4b46ee2a3c22b85b4483f2fd4d0fb916720
      https://github.com/llvm/llvm-project/commit/2ac0c4b46ee2a3c22b85b4483f2fd4d0fb916720
  Author: Ben Langmuir <blangmuir at apple.com>
  Date:   2020-02-11 (Tue, 11 Feb 2020)

  Changed paths:
    M clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
    M clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

  Log Message:
  -----------
  [DirectoryWatcher] Fix misuse of FSEvents API and data race

I observed two bugs in the DirectoryWatcher on macOS

1. We were calling FSEventStreamStop and FSEventStreamInvalidate before
we called FSEventStreamStart and FSEventStreamSetDispatchQueue, if the
DirectoryWatcher was destroyed before the initial async work was done.
This violates the requirements of the FSEvents API.

2. Calls to Receiver could race between the initial work and the
invalidation during destruction.

The second issue is easier to see when using TSan.

Differential Revision: https://reviews.llvm.org/D74371

rdar://59215667




More information about the All-commits mailing list