Skip to content

Commit 1420e44

Browse files
schuayCommit Bot
authored andcommitted
[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 <yangguo@chromium.org> Commit-Queue: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#48024}
1 parent 78446a8 commit 1420e44

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/debug/debug.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,12 @@ bool Debug::Load() {
337337
void Debug::Unload() {
338338
ClearAllBreakPoints();
339339
ClearStepping();
340+
if (FLAG_block_coverage) RemoveAllCoverageInfos();
340341
RemoveDebugDelegate();
341342

342343
// Return debugger is not loaded.
343344
if (!is_loaded()) return;
344345

345-
if (FLAG_block_coverage) RemoveAllCoverageInfos();
346-
347346
// Clear debugger context global handle.
348347
GlobalHandles::Destroy(Handle<Object>::cast(debug_context_).location());
349348
debug_context_ = Handle<Context>();
@@ -642,8 +641,11 @@ void Debug::ApplyBreakPoints(Handle<DebugInfo> debug_info) {
642641
}
643642

644643
void Debug::ClearBreakPoints(Handle<DebugInfo> debug_info) {
644+
// If we attempt to clear breakpoints but none exist, simply return. This can
645+
// happen e.g. CoverageInfos exit but no breakpoints are set.
646+
if (!debug_info->HasDebugBytecodeArray()) return;
647+
645648
DisallowHeapAllocation no_gc;
646-
DCHECK(debug_info->HasDebugBytecodeArray());
647649
for (BreakIterator it(debug_info); !it.Done(); it.Next()) {
648650
it.ClearDebugBreak();
649651
}

0 commit comments

Comments
 (0)