Fix issue 833: eliminate race condition in ProfilerEventsProcessor.
authormikhail.naganov@gmail.com <mikhail.naganov@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 18 Aug 2010 15:36:00 +0000 (15:36 +0000)
committermikhail.naganov@gmail.com <mikhail.naganov@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 18 Aug 2010 15:36:00 +0000 (15:36 +0000)
When under a load, the ProfilerEventsProcessor thread can start
(enter Run) after Stop has been called, thus resetting running_
data member back to 'true', and starting an infinite loop.

BUG=833

Review URL: http://codereview.chromium.org/3157022

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5304 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/cpu-profiler.cc

index 3e554cc..c0ed929 100644 (file)
@@ -46,7 +46,7 @@ static const int kTickSamplesBufferChunksCount = 16;
 
 ProfilerEventsProcessor::ProfilerEventsProcessor(ProfileGenerator* generator)
     : generator_(generator),
-      running_(false),
+      running_(true),
       ticks_buffer_(sizeof(TickSampleEventRecord),
                     kTickSamplesBufferChunkSize,
                     kTickSamplesBufferChunksCount),
@@ -247,7 +247,6 @@ bool ProfilerEventsProcessor::ProcessTicks(unsigned dequeue_order) {
 
 void ProfilerEventsProcessor::Run() {
   unsigned dequeue_order = 0;
-  running_ = true;
 
   while (running_) {
     // Process ticks until we have any.