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

Issue 2581213002: Force HostContentSettingsMap to be destroyed on its owning thread. (Closed)

Created:
4 years ago by gab
Modified:
4 years ago
CC:
chromium-reviews, markusheintz_, msramek+watch_chromium.org, raymes+watch_chromium.org, vmpstr+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Force HostContentSettingsMap to be destroyed on its owning thread. It uses WeakPtrFactory and as such must be destroyed on its owning thread (UI). The rest of the changes can then be inferred from the stack trace on the bug: 1) RefcountedKeyedServiceTraits::Destruct() must check for ThreadTaskRunnerHandle::IsSet() before invoking TTRH::Get(). ** UPDATE in PS 5 : Use STR::RunsTasksOnCurrentThread() instead of STRH comparison. 2) Nothing about RefcountedKeyedService's use of its |task_runner| is thread-affine => using SequencedTaskRunner instead is inline with our desire to make all top-level API use sequence-affinity instead of thread-affinity for thread-safety. 3) Calling SequencedTaskRunnerHandle::IsSet() from the Callback's destructor requires the SequencedWorkerPool's task info to be set in that scope => brought changes from same requirements in another CL @ https://codereview.chromium.org/2491613004/#ps160001 Note: intentionally not adding tests as this change highlights that this deletion is racy in theory (deleting without owning the sequence means potentially deleting things from the same SequenceToken in parallel... any good test would fail TSAN and I also don't want to address this issue given it's long standing and SWP is being replaced by TaskScheduler shortly). 4) Switch to ScopedMockTimeMessageLoopTaskRunner in NotificationPermissionContextTest => otherwise LSAN catches a leak in patch set 3 as the HostContentSettingsMap is sent for deletion on the wrong task runner and the task is never flushed. (ScopedMockTimeMessageLoopTaskRunner ensures the loop is flushed before replacing it, both ways). Precursor requirement to https://codereview.chromium.org/2576243003/ which for some reason makes this destruction race come to life. BUG=674946, 665588, 622400 TBR=mukai (NotificationPermissionContextTest side-effects) Committed: https://crrev.com/28fb80beda6b171647d037057543f77e5b78e170 Cr-Commit-Position: refs/heads/master@{#439534}

Patch Set 1 #

Total comments: 2

Patch Set 2 : fix CookieSettingsTest #

Patch Set 3 : Use ScopedMockTimeMessageLoopTaskRunner in NotificationPermissionContextTest to ensure old MessageL… #

Patch Set 4 : fix compile #

Total comments: 2

Patch Set 5 : s/STRH comparison/RunsTasksOnCurrentThread/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+76 lines, -57 lines) Patch
M base/threading/sequenced_worker_pool.cc View 1 12 chunks +39 lines, -18 lines 0 comments Download
M chrome/browser/notifications/notification_permission_context_unittest.cc View 1 2 3 6 chunks +15 lines, -20 lines 0 comments Download
M components/content_settings/core/browser/cookie_settings_unittest.cc View 1 2 chunks +5 lines, -0 lines 0 comments Download
M components/content_settings/core/browser/host_content_settings_map.cc View 3 chunks +3 lines, -1 line 0 comments Download
M components/keyed_service/core/refcounted_keyed_service.h View 4 chunks +9 lines, -9 lines 0 comments Download
M components/keyed_service/core/refcounted_keyed_service.cc View 1 2 3 4 2 chunks +5 lines, -9 lines 0 comments Download

Messages

Total messages: 58 (37 generated)
gab
@vmpstr for sequenced_worker_pool.cc (copied from https://codereview.chromium.org/2491613004/#ps160001). @erg for components/keyed_service/* @bauerb for components/content_settings/core/browser/host_content_settings_map.cc Thanks, Gab
4 years ago (2016-12-16 17:20:05 UTC) #5
Elliot Glaysher
keyed service lgtm
4 years ago (2016-12-16 18:13:32 UTC) #9
Bernhard Bauer
https://codereview.chromium.org/2581213002/diff/1/components/content_settings/core/browser/host_content_settings_map.cc File components/content_settings/core/browser/host_content_settings_map.cc (right): https://codereview.chromium.org/2581213002/diff/1/components/content_settings/core/browser/host_content_settings_map.cc#newcode831 components/content_settings/core/browser/host_content_settings_map.cc:831: DCHECK(thread_checker_.CalledOnValidThread()); Should this now be a SequenceChecker? And/or have ...
4 years ago (2016-12-16 19:28:45 UTC) #13
gab
https://codereview.chromium.org/2581213002/diff/1/components/content_settings/core/browser/host_content_settings_map.cc File components/content_settings/core/browser/host_content_settings_map.cc (right): https://codereview.chromium.org/2581213002/diff/1/components/content_settings/core/browser/host_content_settings_map.cc#newcode831 components/content_settings/core/browser/host_content_settings_map.cc:831: DCHECK(thread_checker_.CalledOnValidThread()); On 2016/12/16 19:28:45, Bernhard Bauer wrote: > Should ...
4 years ago (2016-12-16 20:42:28 UTC) #14
gab
TBR vmpstr (already reviewed @ https://codereview.chromium.org/2491613004/#ps160001 on behalf of danakj) and dcheng as R-S. TBR ...
4 years ago (2016-12-16 21:16:10 UTC) #18
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/2581213002/40001
4 years ago (2016-12-16 21:17:09 UTC) #22
chromium-reviews
OK, I guess it makes sense that the HCSM knows that it has a stronger ...
4 years ago (2016-12-16 23:57:10 UTC) #23
dcheng
base LGTM
4 years ago (2016-12-17 00:02:50 UTC) #24
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_asan_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_asan_rel_ng/builds/281295)
4 years ago (2016-12-17 00:22:52 UTC) #26
gab
TBR mukai for side-effects on NotificationPermissionContextTest, thanks!
4 years ago (2016-12-17 02:37:40 UTC) #29
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/2581213002/60001
4 years ago (2016-12-17 02:38:28 UTC) #32
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_chromeos_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_chromeos_rel_ng/builds/335161)
4 years ago (2016-12-17 03:02:21 UTC) #34
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/2581213002/70001
4 years ago (2016-12-17 03:04:22 UTC) #37
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_asan_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_asan_rel_ng/builds/281661)
4 years ago (2016-12-17 05:06:38 UTC) #39
Bernhard Bauer
https://codereview.chromium.org/2581213002/diff/70001/components/keyed_service/core/refcounted_keyed_service.cc File components/keyed_service/core/refcounted_keyed_service.cc (right): https://codereview.chromium.org/2581213002/diff/70001/components/keyed_service/core/refcounted_keyed_service.cc#newcode17 components/keyed_service/core/refcounted_keyed_service.cc:17: obj->task_runner_.get() != base::SequencedTaskRunnerHandle::Get()) { Do we have a guarantee ...
4 years ago (2016-12-19 17:07:29 UTC) #42
gab
@erg: PTAL at latest change to refcounted_keyed_service.cc https://codereview.chromium.org/2581213002/diff/70001/components/keyed_service/core/refcounted_keyed_service.cc File components/keyed_service/core/refcounted_keyed_service.cc (right): https://codereview.chromium.org/2581213002/diff/70001/components/keyed_service/core/refcounted_keyed_service.cc#newcode17 components/keyed_service/core/refcounted_keyed_service.cc:17: obj->task_runner_.get() != ...
4 years ago (2016-12-19 18:25:56 UTC) #45
gab
On 2016/12/19 18:25:56, gab wrote: > @erg: PTAL at latest change to refcounted_keyed_service.cc > > ...
4 years ago (2016-12-19 19:59:04 UTC) #49
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/2581213002/90001
4 years ago (2016-12-19 20:02:40 UTC) #52
commit-bot: I haz the power
Committed patchset #5 (id:90001)
4 years ago (2016-12-19 20:10:00 UTC) #55
commit-bot: I haz the power
Patchset 5 (id:??) landed as https://crrev.com/28fb80beda6b171647d037057543f77e5b78e170 Cr-Commit-Position: refs/heads/master@{#439534}
4 years ago (2016-12-19 20:13:47 UTC) #57
yoichio
4 years ago (2016-12-20 02:11:27 UTC) #58
Message was sent while issue was closed.
A revert of this CL (patchset #5 id:90001) has been created in
https://codereview.chromium.org/2587883003/ by yoichio@chromium.org.

The reason for reverting is: This might cause flakiness:
https://bugs.chromium.org/p/chromium/issues/detail?id=675722.

Powered by Google App Engine
This is Rietveld 408576698