|
|
Created:
3 years, 5 months ago by ossu-chromium Modified:
3 years, 5 months ago CC:
chirantan+watch_chromium.org, chromium-reviews, danakj+watch_chromium.org, vmpstr+watch_chromium.org Target Ref:
refs/heads/master Project:
chromium Visibility:
Public. |
DescriptionExpose Timer::AbandonAndStop, so it can safely be destroyed on another thread.
BUG=chromium:736268
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Review-Url: https://codereview.chromium.org/2958003002
Cr-Commit-Position: refs/heads/master@{#484507}
Committed: https://chromium.googlesource.com/chromium/src/+/87340af883f06c363febe752245c1ab1a926a234
Patch Set 1 #Patch Set 2 : Removed AbandonAndStop and made Stop abandon. #
Total comments: 4
Patch Set 3 : Expose AbandonAndStop and use it in AudioInputController. #
Messages
Total messages: 33 (23 generated)
The CQ bit was checked by ossu@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_chromium_compile_dbg_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_comp...)
The CQ bit was checked by ossu@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_chromium_compile_dbg_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_comp...)
The CQ bit was checked by ossu@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by ossu@chromium.org
Patchset #3 (id:40001) has been deleted
ossu@chromium.org changed reviewers: + gab@chromium.org
As I was adding a Timer to a class to do some repeating checks, I stumbled on a problem where tsan would complain if I destroyed that timer (although stopped) in the destructor of my class. I initially worked around that by putting the Timer in an Optional and destroying it directly after stopping, but got some pushback. The problem I was seeing was race between BaseTimerTaskInternal::Run and BaseTimerTaskInternal::Abandon - see the bug. The comment at the top of timer.h seems to indicate that destroying a stopped Timer should be fine on any thread. This change makes all Stops also abandon the task, so during destruction, there's no Abandon call that may interfere with Run. PTAL!
https://codereview.chromium.org/2958003002/diff/20001/base/timer/timer.cc File base/timer/timer.cc (right): https://codereview.chromium.org/2958003002/diff/20001/base/timer/timer.cc#new... base/timer/timer.cc:149: origin_sequence_checker_.DetachFromSequence(); This should allow deletion to happen on any sequence. If abandoning the task is required to happen on sequence you want to have |retain_user_task_ = false| (see 151) which is the default.
https://codereview.chromium.org/2958003002/diff/20001/base/timer/timer.cc File base/timer/timer.cc (right): https://codereview.chromium.org/2958003002/diff/20001/base/timer/timer.cc#new... base/timer/timer.cc:149: origin_sequence_checker_.DetachFromSequence(); On 2017/06/27 21:12:23, gab (slow Tue-Wed) wrote: > This should allow deletion to happen on any sequence. > > If abandoning the task is required to happen on sequence you want to have > |retain_user_task_ = false| (see 151) which is the default. Detaching the checker works fine - the problem I'm seeing is a race between lines 40 and 54 in this file: if (timer_) in the scheduled task and timer_ = nullptr; in Abandon (called in a couple of steps from ~Timer). I tried only abandoning the scheduled task if retain_user_task_ but unfortunately, RepeatingTimer retains the user task and the change will do nothing for my problem. I'm honestly not sure if I should just destroy my RepeatingTimer on the same sequence as its tasks run, or if I should try to find a way to fix this race, or if the race is "fine" and should add a suppression.
https://codereview.chromium.org/2958003002/diff/20001/base/timer/timer.cc File base/timer/timer.cc (right): https://codereview.chromium.org/2958003002/diff/20001/base/timer/timer.cc#new... base/timer/timer.cc:149: origin_sequence_checker_.DetachFromSequence(); On 2017/06/28 14:21:33, ossu-chromium wrote: > On 2017/06/27 21:12:23, gab (slow Tue-Wed) wrote: > > This should allow deletion to happen on any sequence. > > > > If abandoning the task is required to happen on sequence you want to have > > |retain_user_task_ = false| (see 151) which is the default. > > Detaching the checker works fine - the problem I'm seeing is a race between > lines 40 and 54 in this file: if (timer_) in the scheduled task and timer_ = > nullptr; in Abandon (called in a couple of steps from ~Timer). > > I tried only abandoning the scheduled task if retain_user_task_ but > unfortunately, RepeatingTimer retains the user task and the change will do > nothing for my problem. > > I'm honestly not sure if I should just destroy my RepeatingTimer on the same > sequence as its tasks run, or if I should try to find a way to fix this race, or > if the race is "fine" and should add a suppression. I see, should we just publicly expose AbandonAndStop() for users who truly want this (and update the erroneous Timer docs you mentioned)? The current base::Timer impl explicitly tries to avoid trashing by re-using the delayed task and I'm leery to change that without a thorough analysis.
https://codereview.chromium.org/2958003002/diff/20001/base/timer/timer.cc File base/timer/timer.cc (right): https://codereview.chromium.org/2958003002/diff/20001/base/timer/timer.cc#new... base/timer/timer.cc:149: origin_sequence_checker_.DetachFromSequence(); On 2017/07/05 02:36:14, gab (in-out til july17) wrote: > On 2017/06/28 14:21:33, ossu-chromium wrote: > > On 2017/06/27 21:12:23, gab (slow Tue-Wed) wrote: > > > This should allow deletion to happen on any sequence. > > > > > > If abandoning the task is required to happen on sequence you want to have > > > |retain_user_task_ = false| (see 151) which is the default. > > > > Detaching the checker works fine - the problem I'm seeing is a race between > > lines 40 and 54 in this file: if (timer_) in the scheduled task and timer_ = > > nullptr; in Abandon (called in a couple of steps from ~Timer). > > > > I tried only abandoning the scheduled task if retain_user_task_ but > > unfortunately, RepeatingTimer retains the user task and the change will do > > nothing for my problem. > > > > I'm honestly not sure if I should just destroy my RepeatingTimer on the same > > sequence as its tasks run, or if I should try to find a way to fix this race, > or > > if the race is "fine" and should add a suppression. > > I see, should we just publicly expose AbandonAndStop() for users who truly want > this (and update the erroneous Timer docs you mentioned)? The current > base::Timer impl explicitly tries to avoid trashing by re-using the delayed task > and I'm leery to change that without a thorough analysis. Sounds good. It's likely that the change in the current patch set would have unforeseen consequences. I'll make AbandonAndStop public, update the docs and change my timer to use AbandonAndStop instead.
Description was changed from ========== Abandon timer task on Stop, so it can safely be destroyed on another thread. BUG=chromium:736268 ========== to ========== Abandon timer task on Stop, so it can safely be destroyed on another thread. BUG=chromium:736268 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel ==========
Description was changed from ========== Abandon timer task on Stop, so it can safely be destroyed on another thread. BUG=chromium:736268 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel ========== to ========== Expose Timer::AbandonAndStop, so it can safely be destroyed on another thread. BUG=chromium:736268 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel ==========
The CQ bit was checked by ossu@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
ossu@chromium.org changed reviewers: + dalecurtis@chromium.org
I've uploaded a new patch set that moved AbandonAndStop into the public section and updates the comments with what I believe is correct. I've also updated AudioInputController to call AbandonAndStop instead of just Stop. +dalecurtis for AIC review. If this change seems fine, I'll just close the other CL.
media/ lgtm
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
lgtm
The CQ bit was checked by ossu@chromium.org
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch. Bot data: {"patchset_id": 60001, "attempt_start_ts": 1499331448881140, "parent_rev": "73e2be63fc66559cfaed4b5c598c95efe60cb9cc", "commit_rev": "87340af883f06c363febe752245c1ab1a926a234"}
Message was sent while issue was closed.
Description was changed from ========== Expose Timer::AbandonAndStop, so it can safely be destroyed on another thread. BUG=chromium:736268 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel ========== to ========== Expose Timer::AbandonAndStop, so it can safely be destroyed on another thread. BUG=chromium:736268 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel Review-Url: https://codereview.chromium.org/2958003002 Cr-Commit-Position: refs/heads/master@{#484507} Committed: https://chromium.googlesource.com/chromium/src/+/87340af883f06c363febe752245c... ==========
Message was sent while issue was closed.
Committed patchset #3 (id:60001) as https://chromium.googlesource.com/chromium/src/+/87340af883f06c363febe752245c... |