From bddeb844181755d80d48a0881f53f56f8b11d3d3 Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Sun, 26 Nov 2017 23:33:17 -0800 Subject: [PATCH] deps: cherry-pick 1420e44db0 from upstream V8 Original commit message: [coverage] Correctly free DebugInfo in the absence of breakpoints It's quite possible for DebugInfos to exist without the presence of a bytecode array, since DebugInfos are created for all functions for which we have a CoverageInfo. Free such objects properly. Also move the corresponding deletion of CoverageInfos on unload up before the early exit. Bug: v8:6000 Change-Id: Idde45b222290aa8b6828b61ff2251918b8ed2aed Reviewed-on: https://chromium-review.googlesource.com/664811 Reviewed-by: Yang Guo Commit-Queue: Jakob Gruber Cr-Commit-Position: refs/heads/master@{#48024} Fixes crash when passing Profiler.startPreciseCoverage before Debug.paused is received. Refs: https://github.com/v8/v8/commit/1420e44db0ac3631687deb9fc6816ac97b9f499c Refs: https://github.com/bcoe/c8/pull/6#discussion_r153121287 --- common.gypi | 2 +- deps/v8/src/debug/debug.cc | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/common.gypi b/common.gypi index 1645390b899f45..6bf00f7dc8c621 100644 --- a/common.gypi +++ b/common.gypi @@ -27,7 +27,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.12', + 'v8_embedder_string': '-node.13', # Enable disassembler for `--print-code` v8 options 'v8_enable_disassembler': 1, diff --git a/deps/v8/src/debug/debug.cc b/deps/v8/src/debug/debug.cc index e2beaed6abc549..966be62e63617f 100644 --- a/deps/v8/src/debug/debug.cc +++ b/deps/v8/src/debug/debug.cc @@ -338,13 +338,12 @@ bool Debug::Load() { void Debug::Unload() { ClearAllBreakPoints(); ClearStepping(); + if (FLAG_block_coverage) RemoveAllCoverageInfos(); RemoveDebugDelegate(); // Return debugger is not loaded. if (!is_loaded()) return; - if (FLAG_block_coverage) RemoveAllCoverageInfos(); - // Clear debugger context global handle. GlobalHandles::Destroy(Handle::cast(debug_context_).location()); debug_context_ = Handle(); @@ -643,8 +642,11 @@ void Debug::ApplyBreakPoints(Handle debug_info) { } void Debug::ClearBreakPoints(Handle debug_info) { + // If we attempt to clear breakpoints but none exist, simply return. This can + // happen e.g. CoverageInfos exit but no breakpoints are set. + if (!debug_info->HasDebugBytecodeArray()) return; + DisallowHeapAllocation no_gc; - DCHECK(debug_info->HasDebugBytecodeArray()); for (BreakIterator it(debug_info); !it.Done(); it.Next()) { it.ClearDebugBreak(); }