Chromium Code Reviews| Index: base/message_loop.cc |
| =================================================================== |
| --- base/message_loop.cc (revision 85540) |
| +++ base/message_loop.cc (working copy) |
| @@ -8,6 +8,7 @@ |
| #include "base/bind.h" |
| #include "base/compiler_specific.h" |
| +#include "base/debug/alias.h" |
| #include "base/lazy_instance.h" |
| #include "base/logging.h" |
| #include "base/message_pump_default.h" |
| @@ -98,6 +99,14 @@ |
| } |
| void Run() { |
| + // Before running the task, store the program counter where it was posted |
| + // and deliberately alias it to ensure it is on the stack if the task |
| + // crashes. Be careful not to assume that the variable itself will have the |
| + // expected value when displayed by the optimizer in an optimized build. |
| + // Look at a memory dump of the stack. |
| + void* program_counter = task_->get_birth_program_counter(); |
| + base::debug::Alias(&program_counter); |
| + |
| task_->Run(); |
| delete task_; |
| task_ = NULL; |
| @@ -267,6 +276,7 @@ |
| void MessageLoop::PostTask( |
| const tracked_objects::Location& from_here, Task* task) { |
| CHECK(task); |
|
jar (doing other things)
2011/05/18 01:32:34
These checks are probably not needed, now that you
apatrick_chromium
2011/05/18 21:09:47
SetBirthPlace calls are gone so the CHECK is not r
|
| + task->SetBirthPlace(from_here); |
| PendingTask pending_task( |
| base::Bind(&TaskClosureAdapter::Run, |
| new TaskClosureAdapter(task, &should_leak_tasks_)), |
| @@ -278,6 +288,7 @@ |
| void MessageLoop::PostDelayedTask( |
| const tracked_objects::Location& from_here, Task* task, int64 delay_ms) { |
| CHECK(task); |
| + task->SetBirthPlace(from_here); |
| PendingTask pending_task( |
| base::Bind(&TaskClosureAdapter::Run, |
| new TaskClosureAdapter(task, &should_leak_tasks_)), |
| @@ -289,6 +300,7 @@ |
| void MessageLoop::PostNonNestableTask( |
| const tracked_objects::Location& from_here, Task* task) { |
| CHECK(task); |
| + task->SetBirthPlace(from_here); |
| PendingTask pending_task( |
| base::Bind(&TaskClosureAdapter::Run, |
| new TaskClosureAdapter(task, &should_leak_tasks_)), |
| @@ -300,6 +312,7 @@ |
| void MessageLoop::PostNonNestableDelayedTask( |
| const tracked_objects::Location& from_here, Task* task, int64 delay_ms) { |
| CHECK(task); |
| + task->SetBirthPlace(from_here); |
| PendingTask pending_task( |
| base::Bind(&TaskClosureAdapter::Run, |
| new TaskClosureAdapter(task, &should_leak_tasks_)), |
| @@ -767,18 +780,6 @@ |
| delayed_run_time(delayed_run_time), |
| sequence_num(0), |
| nestable(nestable) { |
| -#if defined(TRACK_ALL_TASK_OBJECTS) |
|
apatrick_chromium
2011/05/17 22:48:04
Removing this is wrong but what it does overlaps w
awong
2011/05/17 23:54:01
Corrently...we were trying to make it so Task does
awong
2011/05/17 23:54:55
Corrently -> Correct.
One of these days I will le
jar (doing other things)
2011/05/18 01:32:34
It is similar to, but is not replaced by, what you
apatrick_chromium
2011/05/18 21:09:47
I think I see how this works now. This code block
|
| - if (tracked_objects::ThreadData::IsActive()) { |
| - tracked_objects::ThreadData* current_thread_data = |
| - tracked_objects::ThreadData::current(); |
| - if (current_thread_data) { |
| - post_births = current_thread_data->TallyABirth(posted_from); |
| - } else { |
| - // Shutdown started, and this thread wasn't registered. |
| - post_births = NULL; |
| - } |
| - } |
| -#endif // defined(TRACK_ALL_TASK_OBJECTS) |
| } |
| MessageLoop::PendingTask::~PendingTask() { |