From 0b3e9dc8c6704547485a12f8845695a18a2893c2 Mon Sep 17 00:00:00 2001 From: Ali Ijaz Sheikh Date: Wed, 20 Sep 2017 10:08:26 -0700 Subject: [PATCH] deps: v8: fix potential segfault in profiler This change fixes a potential segfault in the sampling heap profiler. This landed as part of a larger change upstream [1]. This is the minimal backport that avoids the segfault. [1]: https://git.io/vdTYL PR-URL: https://github.com/nodejs/node/pull/15498 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell --- deps/v8/src/profiler/sampling-heap-profiler.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/deps/v8/src/profiler/sampling-heap-profiler.h b/deps/v8/src/profiler/sampling-heap-profiler.h index 0b538b070c49cd..7ea2788bfbcc65 100644 --- a/deps/v8/src/profiler/sampling-heap-profiler.h +++ b/deps/v8/src/profiler/sampling-heap-profiler.h @@ -146,8 +146,11 @@ class SamplingAllocationObserver : public AllocationObserver { void Step(int bytes_allocated, Address soon_object, size_t size) override { USE(heap_); DCHECK(heap_->gc_state() == Heap::NOT_IN_GC); - DCHECK(soon_object); - profiler_->SampleObject(soon_object, size); + if (soon_object) { + // TODO(ofrobots): it would be better to sample the next object rather + // than skipping this sample epoch if soon_object happens to be null. + profiler_->SampleObject(soon_object, size); + } } intptr_t GetNextStepSize() override { return GetNextSampleInterval(rate_); }