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

Issue 8659040: There is a racing between SyncSocket::Receive in audio_thread_ and SyncSocket::Close in renderer ... (Closed)

Created:
9 years ago by no longer working on chromium
Modified:
9 years ago
CC:
chromium-reviews, hclam+watch_chromium.org, ddorwin+watch_chromium.org, fischman+watch_chromium.org, jam, acolwell+watch_chromium.org, annacc+watch_chromium.org, dpranke-watch+content_chromium.org, joi+watch-content_chromium.org, darin-cc_chromium.org, vrk (LEFT CHROMIUM), scherkus (not reviewing), ihf+watch_chromium.org, Chris Rogers
Visibility:
Public.

Description

There is a racing between SyncSocket::Receive in audio_thread_ and SyncSocket::Close in renderer thread. This patch fixes it by using a waitable event to signal the audio thread that it should stop. Test=content_unittests by running Valgrind BUG=103711 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=113386

Patch Set 1 #

Total comments: 13

Patch Set 2 : new proposal from timmi #

Total comments: 13

Patch Set 3 : update #

Unified diffs Side-by-side diffs Delta from patch set Stats (+81 lines, -72 lines) Patch
M content/renderer/media/audio_device.h View 1 2 4 chunks +6 lines, -10 lines 0 comments Download
M content/renderer/media/audio_device.cc View 1 2 7 chunks +30 lines, -21 lines 0 comments Download
M content/renderer/media/audio_input_device.h View 1 2 4 chunks +5 lines, -10 lines 0 comments Download
M content/renderer/media/audio_input_device.cc View 1 2 8 chunks +32 lines, -25 lines 0 comments Download
M content/renderer/media/webrtc_audio_device_impl.cc View 1 2 2 chunks +6 lines, -4 lines 0 comments Download
M content/renderer/renderer_webaudiodevice_impl.cc View 1 2 1 chunk +2 lines, -2 lines 0 comments Download

Messages

Total messages: 40 (0 generated)
no longer working on chromium
Hi all, This CL is trying to fix a racing condition between SyncSocket::Close and SyncSocket::Receive ...
9 years ago (2011-11-29 16:05:02 UTC) #1
enal1
http://codereview.chromium.org/8659040/diff/1/content/renderer/media/audio_device.cc File content/renderer/media/audio_device.cc (right): http://codereview.chromium.org/8659040/diff/1/content/renderer/media/audio_device.cc#newcode29 content/renderer/media/audio_device.cc:29: audio_event_(true, false) { Can you please explain what exactly ...
9 years ago (2011-11-29 16:14:48 UTC) #2
tommi (sloooow) - chröme
http://codereview.chromium.org/8659040/diff/1/content/renderer/media/audio_device.cc File content/renderer/media/audio_device.cc (right): http://codereview.chromium.org/8659040/diff/1/content/renderer/media/audio_device.cc#newcode29 content/renderer/media/audio_device.cc:29: audio_event_(true, false) { I think it's ok to set ...
9 years ago (2011-11-29 16:41:53 UTC) #3
Ami GONE FROM CHROMIUM
drive-by for threading alert. http://codereview.chromium.org/8659040/diff/1/content/renderer/media/audio_input_device.cc File content/renderer/media/audio_input_device.cc (right): http://codereview.chromium.org/8659040/diff/1/content/renderer/media/audio_input_device.cc#newcode292 content/renderer/media/audio_input_device.cc:292: while (!audio_event_.IsSignaled() && I'm not ...
9 years ago (2011-11-29 17:48:32 UTC) #4
tommi (sloooow) - chröme
http://codereview.chromium.org/8659040/diff/1/content/renderer/media/audio_input_device.cc File content/renderer/media/audio_input_device.cc (right): http://codereview.chromium.org/8659040/diff/1/content/renderer/media/audio_input_device.cc#newcode292 content/renderer/media/audio_input_device.cc:292: while (!audio_event_.IsSignaled() && Hey Ami, A couple of questions ...
9 years ago (2011-11-29 20:11:32 UTC) #5
Ami GONE FROM CHROMIUM
http://codereview.chromium.org/8659040/diff/1/content/renderer/media/audio_input_device.cc File content/renderer/media/audio_input_device.cc (right): http://codereview.chromium.org/8659040/diff/1/content/renderer/media/audio_input_device.cc#newcode102 content/renderer/media/audio_input_device.cc:102: LOG(ERROR) << "Failed to shut down audio input on ...
9 years ago (2011-11-29 20:38:15 UTC) #6
enal1
I am not specialist in sockets, but is it possible to send something to it ...
9 years ago (2011-11-29 20:45:08 UTC) #7
Ami GONE FROM CHROMIUM
On 2011/11/29 20:45:08, enal1 wrote: > I am not specialist in sockets, but is it ...
9 years ago (2011-11-29 20:49:40 UTC) #8
enal1
Then I'd say proper fix would be to pass second half of the pair through ...
9 years ago (2011-11-29 21:05:26 UTC) #9
Ami GONE FROM CHROMIUM
On 2011/11/29 21:05:26, enal1 wrote: > Then I'd say proper fix would be to pass ...
9 years ago (2011-11-29 21:06:23 UTC) #10
enal1
i just looked at the Windows base::SyncSocket implementation. It definitely can crash if one thread ...
9 years ago (2011-11-29 21:29:24 UTC) #11
enal1
Re-sending adding Nicholas, he may give more details about native client problem... On Tue, Nov ...
9 years ago (2011-11-29 21:34:39 UTC) #12
nfullagar
So, a few notes, some going back aways: SyncSocket was added way back when, as ...
9 years ago (2011-11-29 23:15:44 UTC) #13
tommi (sloooow) - chröme
Hi everyone, Here's a new proposal that fixes the race issue, avoids the "no data" ...
9 years ago (2011-11-30 10:09:40 UTC) #14
enal1
On 2011/11/30 10:09:40, tommi wrote: > Hi everyone, > > Here's a new proposal that ...
9 years ago (2011-11-30 16:31:52 UTC) #15
no longer working on chromium
Some reply in line. Eugene, I tried Tommi's proposal, but there is still some racing ...
9 years ago (2011-11-30 17:02:54 UTC) #16
enal1
(All my remarks were about output device, I did not look at the input device... ...
9 years ago (2011-11-30 17:48:23 UTC) #17
tommi (sloooow) - chröme
On Wed, Nov 30, 2011 at 6:48 PM, Eugene Nalimov <enal@google.com> wrote: > (All my ...
9 years ago (2011-11-30 18:22:41 UTC) #18
no longer working on chromium
Hi, Tommi helped me found out the reason why I still had race with his ...
9 years ago (2011-12-01 14:28:03 UTC) #19
tommi (sloooow) - chröme
lgtm. good job Shijing. As a general comment, these classes look like twins. We should ...
9 years ago (2011-12-01 14:40:45 UTC) #20
henrika (OOO until Aug 14)
Looks great. LGTM.
9 years ago (2011-12-01 14:56:58 UTC) #21
henrika (OOO until Aug 14)
http://codereview.chromium.org/8659040/diff/21002/content/renderer/media/audio_device.cc File content/renderer/media/audio_device.cc (right): http://codereview.chromium.org/8659040/diff/21002/content/renderer/media/audio_device.cc#newcode81 content/renderer/media/audio_device.cc:81: base::SyncSocket socket(socket_handle_); A comment perhaps?
9 years ago (2011-12-01 14:57:12 UTC) #22
enal1
On 2011/12/01 14:57:12, henrika1 wrote: > http://codereview.chromium.org/8659040/diff/21002/content/renderer/media/audio_device.cc > File content/renderer/media/audio_device.cc (right): > > http://codereview.chromium.org/8659040/diff/21002/content/renderer/media/audio_device.cc#newcode81 > ...
9 years ago (2011-12-01 15:10:36 UTC) #23
Ami GONE FROM CHROMIUM
Removing myself as reviewer. Preventing multiple threads from sharing non-const state is a huge improvement ...
9 years ago (2011-12-01 17:25:28 UTC) #24
no longer working on chromium
Updated the code based on the comments from reviewers. +@rtoy since this will affect the ...
9 years ago (2011-12-02 10:16:30 UTC) #25
tommi (sloooow) - chröme
lgtm++
9 years ago (2011-12-02 10:21:51 UTC) #26
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/xians@chromium.org/8659040/23004
9 years ago (2011-12-05 08:41:07 UTC) #27
commit-bot: I haz the power
Presubmit check for 8659040-23004 failed and returned exit status 1. Running presubmit commit checks ...
9 years ago (2011-12-05 08:41:12 UTC) #28
brettw
content/renderer LGTM
9 years ago (2011-12-06 23:45:57 UTC) #29
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/xians@chromium.org/8659040/23004
9 years ago (2011-12-07 09:25:56 UTC) #30
commit-bot: I haz the power
Try job failure for 8659040-23004 (retry) on win_rel for step "unit_tests". It's a second try, ...
9 years ago (2011-12-07 10:44:45 UTC) #31
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/xians@chromium.org/8659040/23004
9 years ago (2011-12-07 12:22:02 UTC) #32
commit-bot: I haz the power
Change committed as 113386
9 years ago (2011-12-07 14:12:27 UTC) #33
Timur Iskhodzhanov
I assume you've used Memcheck? This is not the right tool to debug data races, ...
9 years ago (2011-12-07 14:21:48 UTC) #34
enal1
On 2011/12/07 14:21:48, Timur Iskhodzhanov wrote: > I assume you've used Memcheck? > This is ...
9 years ago (2011-12-09 23:03:11 UTC) #35
tommi (sloooow) - chröme
You should be able to configure the debugger to not break on that exception - ...
9 years ago (2011-12-10 00:13:52 UTC) #36
enal1
I can, though can every Chrome developer from now to eternity? Is it possible to ...
9 years ago (2011-12-10 01:25:45 UTC) #37
tommi (sloooow) - chröme
That's a good idea. I can do it if you want or if you want, ...
9 years ago (2011-12-10 10:06:27 UTC) #38
enal1
I am pretty busy working on fixing recent regression... On Sat, Dec 10, 2011 at ...
9 years ago (2011-12-12 17:17:19 UTC) #39
no longer working on chromium
9 years ago (2011-12-12 17:43:41 UTC) #40
I can take a look at it when I have time.

I think ref count is a good idea, but we also need to be able to force
closing
the socket when there is no data, so likely an async socket implementation
is needed.

BR,
/SX

On Mon, Dec 12, 2011 at 6:17 PM, Eugene Nalimov <enal@google.com> wrote:

> I am pretty busy working on fixing recent regression...
>
> On Sat, Dec 10, 2011 at 2:06 AM, Tommi <tommi@chromium.org> wrote:
> > That's a good idea.  I can do it if you want or if you want, you can
> send me
> > the review.
> >
> > On Sat, Dec 10, 2011 at 2:25 AM, Eugene Nalimov <enal@google.com> wrote:
> >>
> >> I can, though can every Chrome developer from now to eternity?
> >>
> >> Is it possible to encapsulate socket into ref-counted object that
> >> keeps track of its state? That will also fix potential problem with OS
> >> reusing handle before we closed it for 2nd time, and us closing
> >> absolutely unrelated handle...
> >>
> >> On Fri, Dec 9, 2011 at 4:13 PM, Tommi <tommi@chromium.org> wrote:
> >> > You should be able to configure the debugger to not break on that
> >> > exception
> >> > - although it's not optimal of course.
> >> >
> >> > On Sat, Dec 10, 2011 at 12:03 AM, <enal@google.com> wrote:
> >> >>
> >> >> On 2011/12/07 14:21:48, Timur Iskhodzhanov wrote:
> >> >>>
> >> >>> I assume you've used Memcheck?
> >> >>> This is not the right tool to debug data races, use ThreadSanitizer
> >> >>> instead
> >> >>
> >> >> next
> >> >>>
> >> >>> time:
> >> >>>
> >> >>>
> http://dev.chromium.org/developers/how-tos/using-valgrind/threadsanitizer
> >> >>
> >> >>
> >> >>> Also, please watch the waterfall after commiting as TSan bots may
> >> >>> bark.
> >> >>
> >> >>
> >> >> Did you try to run your change under debugger?
> >> >>
> >> >> On Windows, when running under debugger, I am getting exception
> >> >> "First-chance
> >> >> exception at 0x77aff9e2 in chrome.exe: 0xC0000008: An invalid handle
> >> >> was
> >> >> specified."...
> >> >>
> >> >> That makes it extremely difficult to debug almost any audio-related
> >> >> code...
> >> >>
> >> >> http://codereview.chromium.org/8659040/
> >> >
> >> >
> >
> >
>

Powered by Google App Engine
This is Rietveld 408576698