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

Issue 2529853002: Fix shutdown crash in AudioOutputAuthorizationHandler. (Closed)

Created:
4 years ago by Max Morin
Modified:
4 years ago
Reviewers:
DaleCurtis, o1ka
CC:
audio-mojo-cl_google.com, chromium-reviews, darin-cc_chromium.org, feature-media-reviews_chromium.org, jam, miu+watch_chromium.org, posciak+watch_chromium.org, xjz+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Fix shutdown crash in AudioOutputAuthorizationHandler. If fetching device parameters is scheduled during shutdown, it is possible that the UI thread starts deleting the AudioManager, causing a crash. The problem arises like this: 1. AudioOutputAuthorizationHandler posts GetAudioParametersOnDeviceThread to the audio thread. 2. Shutdown is started, browser threads other than UI are stopped and audio_manager_ in BrowserMainLoop is reset. The causes g_last_created in AudioManager to be nulled and a task to delete the pointer is posted to the audio thread. 3. GetAudioParametersOnDeviceThread runs and calls AudioManager::Get(), which returns g_last_created (i.e. null), and dereferences it, causing a crash. On the contrary, if the AudioManager pointer was stored in AudioOutputAuthorizationhandler and passed into GetAudioParametersOnDeviceThread, we wouldn't have a problem with the UI thread nulling the global pointer. We know that the AudioManager won't be destructed before it fires because the task to destroy the AudioManager is posted after the IO thread is shutdown, and GetAudioParametersOnDeviceThread is posted before/during the shutdown of the IO thread. The AudioManager* is now passed in to the constructor of AudioOutputAuthorizationhandler. Drive-by fix: Remove MakeAuthorizationData, since it's only called form a single place now. The string argument was irrelevant (and even the wrong kind of id). Also a drive-by fix: elimination of bare new in initialization of AudioOutputAuthorizationhandler. BUG=656923, 667981 Committed: https://crrev.com/070d5b996806694c9303f75d9a419392041dec9c Cr-Commit-Position: refs/heads/master@{#434460}

Patch Set 1 #

Patch Set 2 : New fix. #

Patch Set 3 : Add mac comment. #

Total comments: 11

Patch Set 4 : . #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+38 lines, -26 lines) Patch
M content/browser/renderer_host/media/audio_output_authorization_handler.h View 1 2 3 2 chunks +3 lines, -1 line 0 comments Download
M content/browser/renderer_host/media/audio_output_authorization_handler.cc View 1 2 3 3 chunks +16 lines, -5 lines 6 comments Download
M content/browser/renderer_host/media/audio_output_authorization_handler_unittest.cc View 8 chunks +11 lines, -9 lines 0 comments Download
M content/browser/renderer_host/media/audio_renderer_host.cc View 1 2 3 3 chunks +8 lines, -11 lines 0 comments Download

Messages

Total messages: 28 (13 generated)
Max Morin
Olga: WDYT about this approach? I would add comments explaining how the AudioManager lifetime works, ...
4 years ago (2016-11-24 08:26:32 UTC) #3
Max Morin
On 2016/11/24 08:26:32, Max Morin Chromium wrote: > Olga: WDYT about this approach? I would ...
4 years ago (2016-11-24 09:04:41 UTC) #5
Max Morin
PTAL. I'm not sure what the best place to put comments about the audio managers ...
4 years ago (2016-11-24 12:21:03 UTC) #8
o1ka
Nice CL description! lgtm % minor comment clarification. https://codereview.chromium.org/2529853002/diff/40001/content/browser/renderer_host/media/audio_output_authorization_handler.cc File content/browser/renderer_host/media/audio_output_authorization_handler.cc (right): https://codereview.chromium.org/2529853002/diff/40001/content/browser/renderer_host/media/audio_output_authorization_handler.cc#newcode194 content/browser/renderer_host/media/audio_output_authorization_handler.cc:194: // ...
4 years ago (2016-11-24 13:17:36 UTC) #9
Max Morin
https://codereview.chromium.org/2529853002/diff/40001/content/browser/renderer_host/media/audio_output_authorization_handler.cc File content/browser/renderer_host/media/audio_output_authorization_handler.cc (right): https://codereview.chromium.org/2529853002/diff/40001/content/browser/renderer_host/media/audio_output_authorization_handler.cc#newcode194 content/browser/renderer_host/media/audio_output_authorization_handler.cc:194: // Note: |*audio_manager_| outlives the IO thread, so unretained ...
4 years ago (2016-11-24 14:12:21 UTC) #11
o1ka
https://codereview.chromium.org/2529853002/diff/40001/content/browser/renderer_host/media/audio_output_authorization_handler.cc File content/browser/renderer_host/media/audio_output_authorization_handler.cc (right): https://codereview.chromium.org/2529853002/diff/40001/content/browser/renderer_host/media/audio_output_authorization_handler.cc#newcode194 content/browser/renderer_host/media/audio_output_authorization_handler.cc:194: // Note: |*audio_manager_| outlives the IO thread, so unretained ...
4 years ago (2016-11-24 14:34:01 UTC) #12
Max Morin
https://codereview.chromium.org/2529853002/diff/40001/content/browser/renderer_host/media/audio_output_authorization_handler.cc File content/browser/renderer_host/media/audio_output_authorization_handler.cc (right): https://codereview.chromium.org/2529853002/diff/40001/content/browser/renderer_host/media/audio_output_authorization_handler.cc#newcode194 content/browser/renderer_host/media/audio_output_authorization_handler.cc:194: // Note: |*audio_manager_| outlives the IO thread, so unretained ...
4 years ago (2016-11-24 14:49:03 UTC) #14
o1ka
https://codereview.chromium.org/2529853002/diff/40001/content/browser/renderer_host/media/audio_output_authorization_handler.cc File content/browser/renderer_host/media/audio_output_authorization_handler.cc (right): https://codereview.chromium.org/2529853002/diff/40001/content/browser/renderer_host/media/audio_output_authorization_handler.cc#newcode194 content/browser/renderer_host/media/audio_output_authorization_handler.cc:194: // Note: |*audio_manager_| outlives the IO thread, so unretained ...
4 years ago (2016-11-24 15:11:54 UTC) #15
Max Morin
Dale: PTAL at this followup CL. I introduced a subtle bug in the last one. ...
4 years ago (2016-11-24 15:25:41 UTC) #17
DaleCurtis
Seems simpler to just null check and abort processing since we're already in shutdown at ...
4 years ago (2016-11-24 18:11:42 UTC) #18
DaleCurtis
Thanks for fixing!
4 years ago (2016-11-24 18:11:57 UTC) #19
Max Morin
On 2016/11/24 18:11:42, DaleCurtis wrote: > Seems simpler to just null check and abort processing ...
4 years ago (2016-11-25 08:07:39 UTC) #20
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2529853002/60001
4 years ago (2016-11-25 08:08:03 UTC) #23
commit-bot: I haz the power
Committed patchset #4 (id:60001)
4 years ago (2016-11-25 09:00:10 UTC) #26
commit-bot: I haz the power
4 years ago (2016-11-25 09:02:46 UTC) #28
Message was sent while issue was closed.
Patchset 4 (id:??) landed as
https://crrev.com/070d5b996806694c9303f75d9a419392041dec9c
Cr-Commit-Position: refs/heads/master@{#434460}

Powered by Google App Engine
This is Rietveld 408576698