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

Issue 179923006: Attempting to resolve a race condition with PowerMonitor (Closed)

Created:
6 years, 9 months ago by bajones
Modified:
5 years, 7 months ago
CC:
chromium-reviews, extensions-reviews_chromium.org, cbentzel+watch_chromium.org, joi+watch-content_chromium.org, darin-cc_chromium.org, piman+watch_chromium.org, chromium-apps-reviews_chromium.org, erikwright+watch_chromium.org
Visibility:
Public.

Description

Attempting to resolve a race condition with PowerMonitor. ThreadSanitizer caught multiple instances where PowerMonitor::Get or PowerMonitor::Add/RemoveObserver were being called concurrently with the PowerMonitor constructor in the main thread. These functions access a process-global PowerMontior instance (g_power_monitor), which was not thread safe. This change adds locks around PowerMonitor creation and deletion, and forces Add/RemoveObserver to be called in a threadsafe manner. It also removes the need to call PowerMonitor::Get. BUG=268924 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=262018

Patch Set 1 : #

Total comments: 2

Patch Set 2 : Refactored to a more explicitly singleton-like style. #

Total comments: 1

Patch Set 3 : Fixed some Mac issues #

Patch Set 4 : Static interface updates based on feedback from willchan@ #

Total comments: 1

Patch Set 5 : Comment cleanup #

Patch Set 6 : Windows fixes #

Patch Set 7 : Win64 fixes #

Unified diffs Side-by-side diffs Delta from patch set Stats (+142 lines, -122 lines) Patch
M base/power_monitor/power_monitor.h View 1 2 3 2 chunks +15 lines, -15 lines 0 comments Download
M base/power_monitor/power_monitor.cc View 1 2 3 1 chunk +71 lines, -22 lines 0 comments Download
M base/power_monitor/power_monitor_source.h View 1 2 3 4 1 chunk +0 lines, -2 lines 0 comments Download
M base/power_monitor/power_monitor_source.cc View 1 2 3 2 chunks +6 lines, -6 lines 0 comments Download
M base/power_monitor/power_monitor_unittest.cc View 1 2 2 chunks +6 lines, -6 lines 0 comments Download
M base/timer/hi_res_timer_manager_unittest.cc View 1 2 3 4 5 2 chunks +3 lines, -2 lines 0 comments Download
M base/timer/hi_res_timer_manager_win.cc View 1 2 3 4 5 1 chunk +3 lines, -5 lines 0 comments Download
M chrome/browser/extensions/event_router_forwarder_unittest.cc View 1 2 3 2 chunks +5 lines, -2 lines 0 comments Download
M components/nacl/loader/nacl_helper_win_64.cc View 1 2 3 4 5 6 1 chunk +1 line, -1 line 0 comments Download
M components/nacl/loader/nacl_main.cc View 1 2 2 chunks +2 lines, -1 line 0 comments Download
M content/browser/browser_main_loop.h View 1 2 3 2 chunks +0 lines, -2 lines 0 comments Download
M content/browser/browser_main_loop.cc View 1 2 3 1 chunk +2 lines, -2 lines 0 comments Download
M content/browser/power_monitor_message_broadcaster.cc View 1 1 chunk +2 lines, -6 lines 0 comments Download
M content/browser/power_monitor_message_broadcaster_unittest.cc View 1 2 1 chunk +5 lines, -5 lines 0 comments Download
M content/browser/renderer_host/media/media_stream_manager.cc View 1 2 3 2 chunks +2 lines, -10 lines 0 comments Download
M content/child/child_thread.h View 1 2 3 1 chunk +0 lines, -2 lines 0 comments Download
M content/child/child_thread.cc View 1 2 3 1 chunk +4 lines, -4 lines 0 comments Download
M content/child/power_monitor_broadcast_source_unittest.cc View 1 2 2 chunks +6 lines, -6 lines 0 comments Download
M content/gpu/gpu_watchdog_thread.cc View 1 2 chunks +2 lines, -6 lines 0 comments Download
M media/audio/mac/audio_manager_mac.cc View 1 2 3 1 chunk +3 lines, -3 lines 0 comments Download
M net/http/http_network_layer.cc View 1 2 3 4 5 1 chunk +2 lines, -6 lines 0 comments Download
M net/url_request/url_request_job.cc View 1 2 3 4 5 2 chunks +2 lines, -8 lines 0 comments Download

Messages

Total messages: 41 (0 generated)
bajones
PTAL at any files you own. Most are small changes.
6 years, 9 months ago (2014-02-27 23:55:43 UTC) #1
mattm
On 2014/02/27 23:55:43, bajones wrote: > PTAL at any files you own. Most are small ...
6 years, 9 months ago (2014-02-28 00:11:27 UTC) #2
willchan no longer on Chromium
Can you update this CL description? What's the race and what are you doing to ...
6 years, 9 months ago (2014-02-28 00:14:10 UTC) #3
bajones
On 2014/02/28 00:14:10, willchan wrote: > Can you update this CL description? What's the race ...
6 years, 9 months ago (2014-02-28 00:51:43 UTC) #4
Jeffrey Yasskin
event_router_forwarder_unittest.cc lgtm, but I haven't looked at any thread-safety aspects.
6 years, 9 months ago (2014-02-28 00:54:53 UTC) #5
Ken Russell (switch to Gerrit)
https://codereview.chromium.org/179923006/diff/20001/base/power_monitor/power_monitor.h File base/power_monitor/power_monitor.h (right): https://codereview.chromium.org/179923006/diff/20001/base/power_monitor/power_monitor.h#newcode22 base/power_monitor/power_monitor.h:22: static PowerMonitor* Create(scoped_ptr<PowerMonitorSource> source); I find the pattern here ...
6 years, 9 months ago (2014-02-28 02:02:42 UTC) #6
jam
https://codereview.chromium.org/179923006/diff/20001/base/power_monitor/power_monitor.h File base/power_monitor/power_monitor.h (right): https://codereview.chromium.org/179923006/diff/20001/base/power_monitor/power_monitor.h#newcode22 base/power_monitor/power_monitor.h:22: static PowerMonitor* Create(scoped_ptr<PowerMonitorSource> source); On 2014/02/28 02:02:42, Ken Russell ...
6 years, 9 months ago (2014-02-28 17:05:18 UTC) #7
bajones
Thanks Ken, good suggestion! Refactored.
6 years, 9 months ago (2014-02-28 20:08:11 UTC) #8
Ken Russell (switch to Gerrit)
Thanks, that looks much better. LGTM with one suggestion. https://codereview.chromium.org/179923006/diff/40001/base/power_monitor/power_monitor.cc File base/power_monitor/power_monitor.cc (right): https://codereview.chromium.org/179923006/diff/40001/base/power_monitor/power_monitor.cc#newcode38 base/power_monitor/power_monitor.cc:38: ...
6 years, 9 months ago (2014-02-28 21:30:09 UTC) #9
jam
sorry I didn't see this earlier: but now that this is a singleton, we normally ...
6 years, 9 months ago (2014-02-28 21:56:37 UTC) #10
willchan no longer on Chromium
I started skimming this. Is this a problem with how the unit test is constructed, ...
6 years, 9 months ago (2014-02-28 22:15:21 UTC) #11
bajones
On 2014/02/28 22:15:21, willchan wrote: > I started skimming this. Is this a problem with ...
6 years, 9 months ago (2014-03-04 18:55:28 UTC) #12
Ken Russell (switch to Gerrit)
Ping - is this planned to be landed? On the whole it makes the PowerMonitor ...
6 years, 9 months ago (2014-03-27 19:02:10 UTC) #13
bajones
On 2014/03/27 19:02:10, Ken Russell wrote: > Ping - is this planned to be landed? ...
6 years, 9 months ago (2014-03-27 20:06:59 UTC) #14
bradnelson
LGTM for nacl
6 years, 9 months ago (2014-03-27 20:08:33 UTC) #15
mattm
net/url_request lgtm
6 years, 9 months ago (2014-03-28 19:32:31 UTC) #16
bajones
Missed that I also need a LG for media/audio. Could I get a review acolwell@ ...
6 years, 9 months ago (2014-03-28 22:13:11 UTC) #17
acolwell GONE FROM CHROMIUM
lgtm media/
6 years, 9 months ago (2014-03-28 23:45:38 UTC) #18
willchan no longer on Chromium
I think there are improvements to be made in the interface, but I am not ...
6 years, 8 months ago (2014-03-31 19:15:05 UTC) #19
bajones
On 2014/03/31 19:15:05, willchan wrote: > So I'd be fine with you proceeding with moving ...
6 years, 8 months ago (2014-04-02 22:24:20 UTC) #20
willchan no longer on Chromium
I'm not very happy with the friendship relationship of PowerMonitor and PowerMonitorSource, but this changelist ...
6 years, 8 months ago (2014-04-03 23:43:33 UTC) #21
bajones
The CQ bit was checked by bajones@chromium.org
6 years, 8 months ago (2014-04-04 17:25:42 UTC) #22
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/bajones@chromium.org/179923006/120001
6 years, 8 months ago (2014-04-04 17:26:11 UTC) #23
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
6 years, 8 months ago (2014-04-04 18:10:09 UTC) #24
commit-bot: I haz the power
Try jobs failed on following builders: tryserver.chromium on win_chromium_compile_dbg
6 years, 8 months ago (2014-04-04 18:10:10 UTC) #25
bajones
The CQ bit was checked by bajones@chromium.org
6 years, 8 months ago (2014-04-04 19:43:51 UTC) #26
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/bajones@chromium.org/179923006/140001
6 years, 8 months ago (2014-04-04 19:44:38 UTC) #27
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
6 years, 8 months ago (2014-04-04 20:27:30 UTC) #28
commit-bot: I haz the power
Try jobs failed on following builders: tryserver.chromium on win_chromium_compile_dbg
6 years, 8 months ago (2014-04-04 20:27:31 UTC) #29
bajones
The CQ bit was checked by bajones@chromium.org
6 years, 8 months ago (2014-04-04 21:33:33 UTC) #30
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/bajones@chromium.org/179923006/160001
6 years, 8 months ago (2014-04-04 21:38:29 UTC) #31
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
6 years, 8 months ago (2014-04-04 22:14:18 UTC) #32
commit-bot: I haz the power
Try jobs failed on following builders: tryserver.chromium on linux_chromium_rel
6 years, 8 months ago (2014-04-04 22:14:19 UTC) #33
bajones
The CQ bit was checked by bajones@chromium.org
6 years, 8 months ago (2014-04-04 22:49:23 UTC) #34
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/bajones@chromium.org/179923006/160001
6 years, 8 months ago (2014-04-04 22:49:37 UTC) #35
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
6 years, 8 months ago (2014-04-05 01:47:56 UTC) #36
commit-bot: I haz the power
Try jobs failed on following builders: tryserver.chromium on mac_chromium_rel
6 years, 8 months ago (2014-04-05 01:47:57 UTC) #37
bajones
The CQ bit was checked by bajones@chromium.org
6 years, 8 months ago (2014-04-05 16:54:18 UTC) #38
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/bajones@chromium.org/179923006/160001
6 years, 8 months ago (2014-04-05 16:54:21 UTC) #39
commit-bot: I haz the power
Change committed as 262018
6 years, 8 months ago (2014-04-05 17:28:42 UTC) #40
scottmg
6 years, 8 months ago (2014-04-05 18:55:25 UTC) #41
Message was sent while issue was closed.
A revert of this CL has been created in
https://codereview.chromium.org/226263008/ by scottmg@chromium.org.

The reason for reverting is: Failing interactive_ui_tests dbg:

http://build.chromium.org/p/chromium.win/builders/Interactive%20Tests%20(dbg)....

Powered by Google App Engine
This is Rietveld 408576698