Page MenuHomePhabricator

[DirectoryWatcher] Fix misuse of FSEvents API and data race
ClosedPublic

Authored by benlangmuir on Feb 10 2020, 5:48 PM.

Details

Summary

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.
  1. Calls to Receiver could race between the initial work and the invalidation during destruction.

The second issue is easier to see when using TSan.

rdar://59215667

Diff Detail

Event Timeline

benlangmuir created this revision.Feb 10 2020, 5:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 10 2020, 5:48 PM
jkorous accepted this revision.Feb 10 2020, 5:51 PM

LGTM

Thanks!

This revision is now accepted and ready to land.Feb 10 2020, 5:51 PM
This revision was automatically updated to reflect the committed changes.