Skip to content

Commit

Permalink
deps: v8: fix potential segfault in profiler
Browse files Browse the repository at this point in the history
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: nodejs#15498
Backport-PR-URL: nodejs#16413
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
ofrobots authored and gibfahn committed Jan 16, 2018
1 parent 694291b commit 416944e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions deps/v8/src/profiler/sampling-heap-profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,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_); }
Expand Down

0 comments on commit 416944e

Please sign in to comment.