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

Unified Diff: base/threading/post_task_and_reply_impl.cc

Issue 2236993004: Annotate PostTaskAndReplyRelay as being self-managed and potentially leaked in PostTaskAndReplyImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@b1_afterstartup_runner
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/post_task_and_reply_impl.cc
diff --git a/base/threading/post_task_and_reply_impl.cc b/base/threading/post_task_and_reply_impl.cc
index d928dc882ac62fa890e29af9849741af78360e0b..7899f65f94bd792e3f9bd2f277a9e11595e590b7 100644
--- a/base/threading/post_task_and_reply_impl.cc
+++ b/base/threading/post_task_and_reply_impl.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/callback.h"
+#include "base/debug/leak_annotations.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/sequence_checker.h"
@@ -82,6 +83,12 @@ bool PostTaskAndReplyImpl::PostTaskAndReply(
DCHECK(!reply.is_null()) << from_here.ToString();
PostTaskAndReplyRelay* relay =
new PostTaskAndReplyRelay(from_here, task, reply);
+ // PostTaskAndReplyRelay self-destructs after executing |reply|. On the flip
+ // side though, it is intentionally leaked if the |task| doesn't complete
+ // before the origin sequence stops executing tasks. Annotate |relay| as leaky
+ // to avoid having to suppress every callsite which happens to flakily trigger
+ // this race.
+ ANNOTATE_LEAKING_OBJECT_PTR(relay);
if (!PostTask(from_here, Bind(&PostTaskAndReplyRelay::RunTaskAndPostReply,
Unretained(relay)))) {
delete relay;
« no previous file with comments | « no previous file | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698