Reviewers: Michail Naganov,

Message:
This is the patch for the Logger bug from
http://codereview.chromium.org/2841023/show ported to bleeding_edge.

Thanks
  Luke


http://codereview.chromium.org/2843023/diff/1/2
File src/log.cc (right):

http://codereview.chromium.org/2843023/diff/1/2#newcode310
src/log.cc:310: void Profiler::Run() {
Would it be helpful to ASSERT(Logger::profiler_ == this)?

Description:
Avoid a potential null dereference wrt the CPU profiler.

GetActiveProfilerModules()/PauseProfiler()/ResumeProfiler() can be reached
from the API when the --prof runtime flag is not set, leading to null
dereferences. Verify that Logger::profiler_ is non-NULL before using it.


Please review this at http://codereview.chromium.org/2843023/show

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
  M     src/log.cc


Index: src/log.cc
===================================================================
--- src/log.cc  (revision 4944)
+++ src/log.cc  (working copy)
@@ -309,10 +309,10 @@

 void Profiler::Run() {
   TickSample sample;
-  bool overflow = Logger::profiler_->Remove(&sample);
+  bool overflow = Remove(&sample);
   while (running_) {
     LOG(TickEvent(&sample, overflow));
-    overflow = Logger::profiler_->Remove(&sample);
+    overflow = Remove(&sample);
   }
 }

@@ -1150,7 +1150,7 @@

 int Logger::GetActiveProfilerModules() {
   int result = PROFILER_MODULE_NONE;
-  if (!profiler_->paused()) {
+  if (profiler_ != NULL && !profiler_->paused()) {
     result |= PROFILER_MODULE_CPU;
   }
   if (FLAG_log_gc) {
@@ -1162,7 +1162,7 @@

 void Logger::PauseProfiler(int flags, int tag) {
   if (!Log::IsEnabled()) return;
-  if (flags & PROFILER_MODULE_CPU) {
+  if (profiler_ != NULL && (flags & PROFILER_MODULE_CPU)) {
     // It is OK to have negative nesting.
     if (--cpu_profiler_nesting_ == 0) {
       profiler_->pause();
@@ -1193,7 +1193,7 @@
   if (tag != 0) {
     UncheckedIntEvent("open-tag", tag);
   }
-  if (flags & PROFILER_MODULE_CPU) {
+  if (profiler_ != NULL && (flags & PROFILER_MODULE_CPU)) {
     if (cpu_profiler_nesting_++ == 0) {
       ++logging_nesting_;
       if (FLAG_prof_lazy) {


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to