Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Issue 149630: Fix two races in DirectoryWatcherInotify: (Closed)

Created:
11 years, 5 months ago by Paweł Hajdan Jr.
Modified:
9 years, 7 months ago
CC:
chromium-reviews_googlegroups.com
Visibility:
Public.

Description

Fix two races in DirectoryWatcherInotify: 1. In DirectoryWatcherImpl::Watch we have to initialize delegate_, root_path_ and other members before calling InotifyReader::AddWatch, because otherwise the following race is possible: 1. InotifyReader::AddWatch 2. DirectoryWatcherImpl::OnInotifyEvent, where we want to use delegate_ and root_path_ 3. Now-late initialization of delegate_ and root_path_ in DirectoryWatcherImpl::Watch 2. In InotifyReader::OnInotifyEvent we can't just copy things under a lock and notify without a lock. Otherwise the following race is possible: 1. Things get copied in InotifyReader::OnInotifyEvent, lock is released 2. DirectoryWatcherImpl is destroyed, removing its watch 3. But it's still in the copied set of watchers to be notified. When we get to notifying it, it's invalid, and we have a crash. To fix race #2, I decided to just do everything under the lock. Notifications shouldn't be a bottleneck, and I don't want to prematurely add more complexity. TEST=Manually with RaceChecker, see bug. http://crbug.com/15473 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=20730

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+13 lines, -18 lines) Patch
M base/directory_watcher_inotify.cc View 3 chunks +13 lines, -18 lines 0 comments Download

Messages

Total messages: 4 (0 generated)
Paweł Hajdan Jr.
Please review: Evan: the code. Aaron: do you have any objections about doing all notifications ...
11 years, 5 months ago (2009-07-14 20:36:56 UTC) #1
Evan Martin
LGTM
11 years, 5 months ago (2009-07-14 20:39:01 UTC) #2
Aaron Boodman
LGTM On Tue, Jul 14, 2009 at 1:39 PM, <evan@chromium.org> wrote: > LGTM > > ...
11 years, 5 months ago (2009-07-14 21:22:30 UTC) #3
the_wrong_timurrrr
11 years, 5 months ago (2009-07-15 09:14:01 UTC) #4
On 2009/07/14 20:36:56, Paweł Hajdan Jr. wrote:
> Please review:
> 
> Evan: the code.
> Aaron: do you have any objections about doing all notifications under the
lock?
> For now the primary user of DirectoryWatcher is extension system.
> 
> timurrrr: Thanks for catching the issues. Could you verify that they are gone
> after applying this patch?
LGTM

Powered by Google App Engine
This is Rietveld 408576698