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

Issue 271033: Multiple sync channels if used in the same listener thread could result in ca... (Closed)

Created:
11 years, 2 months ago by ananta
Modified:
9 years, 6 months ago
Reviewers:
agl, jam
CC:
chromium-reviews_googlegroups.com, brettw+cc_chromium.org, ben+cc_chromium.org, jam, Paweł Hajdan Jr., darin (slow to review), tim (not reviewing)
Visibility:
Public.

Description

John, please review everything. agl, please review changes to the waitable_event_watcher code. Multiple sync channels if used in the same listener thread could result in calls completing in the wrong context at times. This happens if there are nested calls on these sync channels, i.e 1. Call from client 1 on channel 1 to server 1. Message pumping is enabled for the corresponding message 2. Call from client 2 on channel 2 to server 2, Message pumping is enabled for the corresponding message Now if a reply for 1 arrives, it should be queued until reply 2 arrives. This does not happen which causes 2 to terminate prematurely leading to crashes, 1 waiting indefinitely at times, etc. The fix for this issue is to maintain a local global stack for the send done event watcher object. The global object is in the form of a TLS. This ensures that we only watch for completed events on the outermost sync channel. The changes in the Waitable event watcher object are to return the current delegate which is needed to start watching the old send watcher once we are done and to ensure that the event member is set even if it was already signaled when StartWatching was called. I have added a unit test in ipc_tests for this case. I removed the old QueuedReply based unit tests as they did not test the actual nested call case. While debugging these issues I also found some issues in BrowserRenderProcessHost::OnChannelError where it would delete a sync channel while it was in use. Based on a discussion with jam we decided to DeleteSoon the sync channel pointer. However this broke some browser ui tests which relied on the timing of the OnChannelError notification. We decided to leave the existing code as is for now. I removed the DCHECK on channel as it would fire repeatedly if the channel died while multiple sync calls were waiting to complete leading to OnChannelError firing multiple times. Bug=24427 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=28967

Patch Set 1 #

Patch Set 2 : '' #

Patch Set 3 : '' #

Total comments: 2

Patch Set 4 : '' #

Patch Set 5 : '' #

Patch Set 6 : '' #

Patch Set 7 : '' #

Patch Set 8 : '' #

Total comments: 6

Patch Set 9 : '' #

Patch Set 10 : '' #

Patch Set 11 : '' #

Patch Set 12 : '' #

Patch Set 13 : '' #

Patch Set 14 : '' #

Patch Set 15 : '' #

Total comments: 3

Patch Set 16 : '' #

Patch Set 17 : '' #

Total comments: 2

Patch Set 18 : '' #

Patch Set 19 : '' #

Patch Set 20 : '' #

Patch Set 21 : '' #

Patch Set 22 : '' #

Total comments: 6

Patch Set 23 : '' #

Patch Set 24 : '' #

Patch Set 25 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+148 lines, -78 lines) Patch
M base/waitable_event_watcher.h View 12 13 14 15 3 chunks +9 lines, -1 line 0 comments Download
M base/waitable_event_watcher_posix.cc View 13 14 15 16 17 18 19 20 4 chunks +7 lines, -2 lines 0 comments Download
M chrome/browser/renderer_host/browser_render_process_host.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 chunk +5 lines, -1 line 0 comments Download
M ipc/ipc_sync_channel.h View 12 13 14 15 16 17 18 19 20 21 22 2 chunks +4 lines, -1 line 0 comments Download
M ipc/ipc_sync_channel.cc View 12 13 14 15 16 17 18 19 20 21 22 4 chunks +44 lines, -6 lines 0 comments Download
M ipc/ipc_sync_channel_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 4 chunks +74 lines, -67 lines 0 comments Download
M ipc/ipc_sync_message_unittest.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 2 chunks +5 lines, -0 lines 0 comments Download

Messages

Total messages: 16 (0 generated)
ananta
11 years, 2 months ago (2009-10-09 15:54:59 UTC) #1
jam
http://codereview.chromium.org/271033/diff/6001/6004 File ipc/ipc_sync_channel_unittest.cc (right): http://codereview.chromium.org/271033/diff/6001/6004#newcode488 Line 488: // defined above. This should be done now ...
11 years, 2 months ago (2009-10-09 17:01:21 UTC) #2
ananta
http://codereview.chromium.org/271033/diff/6001/6004 File ipc/ipc_sync_channel_unittest.cc (right): http://codereview.chromium.org/271033/diff/6001/6004#newcode488 Line 488: // defined above. On 2009/10/09 17:01:22, John Abd-El-Malek ...
11 years, 2 months ago (2009-10-09 18:11:31 UTC) #3
jam
http://codereview.chromium.org/271033/diff/1010/1013 File ipc/ipc_sync_channel_unittest.cc (right): http://codereview.chromium.org/271033/diff/1010/1013#newcode649 Line 649: // The NestedSyncChannelsIPCsServer1 and NestedSyncChannelsIPCsServer1 classes Why not ...
11 years, 2 months ago (2009-10-09 21:55:28 UTC) #4
ananta
http://codereview.chromium.org/271033/diff/1010/1013 File ipc/ipc_sync_channel_unittest.cc (right): http://codereview.chromium.org/271033/diff/1010/1013#newcode649 Line 649: // The NestedSyncChannelsIPCsServer1 and NestedSyncChannelsIPCsServer1 classes On 2009/10/09 ...
11 years, 2 months ago (2009-10-09 22:12:14 UTC) #5
ananta
I have added the ipc_sync_channel.cc/.h files to this CL. The fix is to maintain a ...
11 years, 2 months ago (2009-10-10 01:49:16 UTC) #6
jam
http://codereview.chromium.org/271033/diff/15/6018 File ipc/ipc_sync_channel.cc (right): http://codereview.chromium.org/271033/diff/15/6018#newcode427 Line 427: g_top_send_done_watcher(base::LINKER_INITIALIZED); why not reuse ReceivedSyncMsgQueue, so we can ...
11 years, 2 months ago (2009-10-12 19:58:10 UTC) #7
ananta
http://codereview.chromium.org/271033/diff/15/6018 File ipc/ipc_sync_channel.cc (right): http://codereview.chromium.org/271033/diff/15/6018#newcode427 Line 427: g_top_send_done_watcher(base::LINKER_INITIALIZED); On 2009/10/12 19:58:10, John Abd-El-Malek wrote: > ...
11 years, 2 months ago (2009-10-12 23:27:24 UTC) #8
ananta
11 years, 2 months ago (2009-10-12 23:34:45 UTC) #9
agl
http://codereview.chromium.org/271033/diff/4011/5019 File base/waitable_event_watcher_posix.cc (left): http://codereview.chromium.org/271033/diff/4011/5019#oldcode172 Line 172: message_loop_ = current_ml; I understand that you want ...
11 years, 2 months ago (2009-10-13 02:25:35 UTC) #10
ananta
http://codereview.chromium.org/271033/diff/4011/5019 File base/waitable_event_watcher_posix.cc (left): http://codereview.chromium.org/271033/diff/4011/5019#oldcode172 Line 172: message_loop_ = current_ml; On 2009/10/13 02:25:35, agl wrote: ...
11 years, 2 months ago (2009-10-13 02:36:43 UTC) #11
ananta
Hi Adam Based on our discussion I changed the code to just set the event_ ...
11 years, 2 months ago (2009-10-13 02:50:35 UTC) #12
agl
WaitableEvent stuff: LGTM
11 years, 2 months ago (2009-10-13 18:09:21 UTC) #13
jam
http://codereview.chromium.org/271033/diff/15/6018 File ipc/ipc_sync_channel.cc (right): http://codereview.chromium.org/271033/diff/15/6018#newcode427 Line 427: g_top_send_done_watcher(base::LINKER_INITIALIZED); On 2009/10/12 23:27:24, ananta wrote: > On ...
11 years, 2 months ago (2009-10-13 19:26:29 UTC) #14
jam
lgtm http://codereview.chromium.org/271033/diff/7029/1047 File ipc/ipc_sync_channel.cc (right): http://codereview.chromium.org/271033/diff/7029/1047#newcode444 Line 444: SyncChannel::ReceivedSyncMsgQueue::lazy_tls_ptr_.Pointer()->Get(); no need to use the tls ...
11 years, 2 months ago (2009-10-13 21:24:36 UTC) #15
ananta
11 years, 2 months ago (2009-10-13 21:35:16 UTC) #16
http://codereview.chromium.org/271033/diff/7029/1047
File ipc/ipc_sync_channel.cc (right):

http://codereview.chromium.org/271033/diff/7029/1047#newcode444
Line 444: SyncChannel::ReceivedSyncMsgQueue::lazy_tls_ptr_.Pointer()->Get();
On 2009/10/13 21:24:36, John Abd-El-Malek wrote:
> no need to use the tls pointer for this, can call
> sync_context() and add a getter to it for received_sync_msgs_

Done.

http://codereview.chromium.org/271033/diff/7029/1047#newcode447
Line 447: base::WaitableEventWatcher* old_send_done_event_watcher = NULL;
On 2009/10/13 21:24:36, John Abd-El-Malek wrote:
> nit: why set it to null and then set it to another value on the second line? 
i
> think it's clearer to just do it in one statement

Done.

http://codereview.chromium.org/271033/diff/7029/1044
File ipc/ipc_sync_message_unittest.h (right):

http://codereview.chromium.org/271033/diff/7029/1044#newcode6
Line 6: #include <string>
On 2009/10/13 21:24:36, John Abd-El-Malek wrote:
> nit: this should be the first include

Done.

Powered by Google App Engine
This is Rietveld 408576698