New issue
Advanced search Search tips

Issue 740692 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Jul 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Chrome
Pri: 1
Type: Bug

Blocking:
issue 740305



Sign in to add a comment

MessageLoopForIOOnOtherThread/FileDescriptorWatcherTest.WatchWritable/0 fails if WatchWritable actually CHECKs that the watch succeeds

Project Member Reported by w...@chromium.org, Jul 10 2017

Issue description

While debugging a file descriptor watchability bug for Fuchsia I added a CHECK to the FileDescriptorWatcher POSIX wrapper to ensure that the watch is actually succeeding, since that code was ignoring the return-value from MessageLoopForIO::WatchFileDescriptor().

On Linux the WatchFileDescriptor() call [in the unit test] actually fails, in the libevent:event_add() call. Since several call-sites (e.g. DBUS integration) rely on writability events, we should determine if this is a real breakage, or a test-only issue.
 

Comment 1 by w...@chromium.org, Jul 10 2017

Status: Started (was: Untriaged)

Comment 2 by w...@chromium.org, Jul 10 2017

Cc: fdoray@chromium.org
Summary: MessageLoopForIOOnOtherThread/FileDescriptorWatcherTest.WatchWritable/0 fails if WatchWritable actually CHECKs that the watch succeeds (was: MessageLoop*FileDescriptorWatcher*WatchWritable* fails if WatchWritable actually CHECKs that the watch succeeds)
Noticed that MessageLoopForIOOnOtherThread/FileDescriptorWatcherTest.WatchWritable/0 failed, but MessageLoopForIOOnOtherThread/FileDescriptorWatcherTest.WatchWritable/0 succeeded, which suggested a thread race was the trigger.

The test fixture Start()s the |other_thread_| but does not wait for it to actually finish starting (Start() became asynchronous in https://codereview.chromium.org/1131513007), and adding the wait gets things working again, but FileDescriptorWatcher already needs to cope with that case, so that's not a real fix.

However, without the wait, it is possible for the test fixture to reach TearDown, and close the |pipe_fds_|, before joining |other_read_|, and for it to do so before |other_thread_| has a chance to be scheduled.

Comment 3 by w...@chromium.org, Jul 11 2017

Blocking: 740305
Project Member

Comment 4 by bugdroid1@chromium.org, Jul 11 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/073c953fe21a412e94d29799558d0a90079a5c84

commit 073c953fe21a412e94d29799558d0a90079a5c84
Author: Wez <wez@chromium.org>
Date: Tue Jul 11 22:30:10 2017

Create FakeLauncher with a pipe in SingleSendMessageRead test.

Passing a file-system backed base::File to report as the NativeMessaging
host process' stdout causes the WatchReadable on the descriptor to
silently fail.

Passing a Unix pipe avoids that (which is a pre-requisite for switching
FileDescriptorWatcher::WatchReadable() to [D]CHECK on failure) and also
allows us to remove the explicit call to ReadNowForTesting().

Bug= 740692 

Change-Id: I76eacf530cf32b7cd490f2d3bf9a07f083909949
Reviewed-on: https://chromium-review.googlesource.com/566987
Commit-Queue: Wez <wez@chromium.org>
Reviewed-by: Sergey Ulanov <sergeyu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#485697}
[modify] https://crrev.com/073c953fe21a412e94d29799558d0a90079a5c84/chrome/browser/extensions/api/messaging/native_message_process_host.cc
[modify] https://crrev.com/073c953fe21a412e94d29799558d0a90079a5c84/chrome/browser/extensions/api/messaging/native_message_process_host.h
[modify] https://crrev.com/073c953fe21a412e94d29799558d0a90079a5c84/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc

Project Member

Comment 5 by bugdroid1@chromium.org, Jul 12 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/45df4f39f6468b5f115462a5dbf49d453a5fc154

commit 45df4f39f6468b5f115462a5dbf49d453a5fc154
Author: Wez <wez@chromium.org>
Date: Wed Jul 12 02:52:29 2017

Fix threading in FileDescriptorWatcher and MessagePumpLibevent tests.

Changes to MessagePumpLibevent & tests:
1. Add an explicit wait for thread start-up to TestWatchingFromBadThread,
which was not updated when the base::ThreadStart() call was changed to
not wait for the thread startup to complete.
2. Reinstate TestWatchingFromBadThread on all libevent platforms.
3. Add sanity-check tests for readable/writable notifications.
4. Clean up some .get()s and add some DPLOGs.

Changes to FileDescriptorWatcher & tests:
1. Add a DLOG_IF() to StartWatching, to make it easier to spot
WatchFileDescriptor failures. This can't be a DCHECK or CHECK, since the
StartWatching operation is racey with file-descriptor close() on the
calling thread.
2. Fix the test fixture to Stop() |other_thread_| to ensure it is done
working before we tear down the test file descriptors.
3. Fix the WatchWritable test to request write notifications for the
correct end of the pipe (since pipe()s are uni-directional).

Bug:  138845 , 740692 

TBR=dcheng,fdoray

Change-Id: I86bdd100561fbc56c1e6291216cafc3168b185dc
Reviewed-on: https://chromium-review.googlesource.com/565227
Commit-Queue: Wez <wez@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Wez <wez@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#485822}
[modify] https://crrev.com/45df4f39f6468b5f115462a5dbf49d453a5fc154/base/files/file_descriptor_watcher_posix.cc
[modify] https://crrev.com/45df4f39f6468b5f115462a5dbf49d453a5fc154/base/files/file_descriptor_watcher_posix_unittest.cc
[modify] https://crrev.com/45df4f39f6468b5f115462a5dbf49d453a5fc154/base/message_loop/message_pump_libevent.cc
[modify] https://crrev.com/45df4f39f6468b5f115462a5dbf49d453a5fc154/base/message_loop/message_pump_libevent_unittest.cc

Project Member

Comment 6 by bugdroid1@chromium.org, Jul 12 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/834ed117a4b677e9868556b8d7ad8d2aeb622413

commit 834ed117a4b677e9868556b8d7ad8d2aeb622413
Author: Christopher Lam <calamity@chromium.org>
Date: Wed Jul 12 03:28:31 2017

Revert "Fix threading in FileDescriptorWatcher and MessagePumpLibevent tests."

This reverts commit 45df4f39f6468b5f115462a5dbf49d453a5fc154.

Reason for revert: compile fail due to unused variable https://build.chromium.org/p/chromium/builders/Linux%20x64/builds/43945

Original change's description:
> Fix threading in FileDescriptorWatcher and MessagePumpLibevent tests.
> 
> Changes to MessagePumpLibevent & tests:
> 1. Add an explicit wait for thread start-up to TestWatchingFromBadThread,
> which was not updated when the base::ThreadStart() call was changed to
> not wait for the thread startup to complete.
> 2. Reinstate TestWatchingFromBadThread on all libevent platforms.
> 3. Add sanity-check tests for readable/writable notifications.
> 4. Clean up some .get()s and add some DPLOGs.
> 
> Changes to FileDescriptorWatcher & tests:
> 1. Add a DLOG_IF() to StartWatching, to make it easier to spot
> WatchFileDescriptor failures. This can't be a DCHECK or CHECK, since the
> StartWatching operation is racey with file-descriptor close() on the
> calling thread.
> 2. Fix the test fixture to Stop() |other_thread_| to ensure it is done
> working before we tear down the test file descriptors.
> 3. Fix the WatchWritable test to request write notifications for the
> correct end of the pipe (since pipe()s are uni-directional).
> 
> Bug:  138845 , 740692 
> 
> TBR=dcheng,fdoray
> 
> Change-Id: I86bdd100561fbc56c1e6291216cafc3168b185dc
> Reviewed-on: https://chromium-review.googlesource.com/565227
> Commit-Queue: Wez <wez@chromium.org>
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> Reviewed-by: Wez <wez@chromium.org>
> Reviewed-by: Nico Weber <thakis@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#485822}

TBR=dcheng@chromium.org,wez@chromium.org,thakis@chromium.org,fdoray@chromium.org,sergeyu@chromium.org

Change-Id: Idbb8c3cc0f6889c546195e62df552241d67312b9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug:  138845 ,  740692 
Reviewed-on: https://chromium-review.googlesource.com/566839
Reviewed-by: Christopher Lam <calamity@chromium.org>
Commit-Queue: Christopher Lam <calamity@chromium.org>
Cr-Commit-Position: refs/heads/master@{#485825}
[modify] https://crrev.com/834ed117a4b677e9868556b8d7ad8d2aeb622413/base/files/file_descriptor_watcher_posix.cc
[modify] https://crrev.com/834ed117a4b677e9868556b8d7ad8d2aeb622413/base/files/file_descriptor_watcher_posix_unittest.cc
[modify] https://crrev.com/834ed117a4b677e9868556b8d7ad8d2aeb622413/base/message_loop/message_pump_libevent.cc
[modify] https://crrev.com/834ed117a4b677e9868556b8d7ad8d2aeb622413/base/message_loop/message_pump_libevent_unittest.cc

Project Member

Comment 7 by bugdroid1@chromium.org, Jul 12 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/1be89cc40709005f1c462c8d558f25eb7e6b49be

commit 1be89cc40709005f1c462c8d558f25eb7e6b49be
Author: Wez <wez@chromium.org>
Date: Wed Jul 12 06:44:49 2017

Reland "Fix threading in FileDescriptorWatcher and MessagePumpLibevent tests."

This is a reland of 45df4f39f6468b5f115462a5dbf49d453a5fc154
Original change's description:
> Fix threading in FileDescriptorWatcher and MessagePumpLibevent tests.
> 
> Changes to MessagePumpLibevent & tests:
> 1. Add an explicit wait for thread start-up to TestWatchingFromBadThread,
> which was not updated when the base::ThreadStart() call was changed to
> not wait for the thread startup to complete.
> 2. Reinstate TestWatchingFromBadThread on all libevent platforms.
> 3. Add sanity-check tests for readable/writable notifications.
> 4. Clean up some .get()s and add some DPLOGs.
> 
> Changes to FileDescriptorWatcher & tests:
> 1. Add a DLOG_IF() to StartWatching, to make it easier to spot
> WatchFileDescriptor failures. This can't be a DCHECK or CHECK, since the
> StartWatching operation is racey with file-descriptor close() on the
> calling thread.
> 2. Fix the test fixture to Stop() |other_thread_| to ensure it is done
> working before we tear down the test file descriptors.
> 3. Fix the WatchWritable test to request write notifications for the
> correct end of the pipe (since pipe()s are uni-directional).
> 
> Bug:  138845 , 740692 
> 
> TBR=dcheng,fdoray
> 
> Change-Id: I86bdd100561fbc56c1e6291216cafc3168b185dc
> Reviewed-on: https://chromium-review.googlesource.com/565227
> Commit-Queue: Wez <wez@chromium.org>
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> Reviewed-by: Wez <wez@chromium.org>
> Reviewed-by: Nico Weber <thakis@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#485822}

TBR: dcheng, thakis
Bug:  138845 ,  740692 
Change-Id: Ibc6e48316351b311bfa06727964bbcf4cf5e699b
Reviewed-on: https://chromium-review.googlesource.com/566840
Reviewed-by: Wez <wez@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#485880}
[modify] https://crrev.com/1be89cc40709005f1c462c8d558f25eb7e6b49be/base/files/file_descriptor_watcher_posix.cc
[modify] https://crrev.com/1be89cc40709005f1c462c8d558f25eb7e6b49be/base/files/file_descriptor_watcher_posix_unittest.cc
[modify] https://crrev.com/1be89cc40709005f1c462c8d558f25eb7e6b49be/base/message_loop/message_pump_libevent.cc
[modify] https://crrev.com/1be89cc40709005f1c462c8d558f25eb7e6b49be/base/message_loop/message_pump_libevent_unittest.cc

Comment 8 by w...@chromium.org, Jul 12 2017

Status: Fixed (was: Started)

Sign in to add a comment