Commit 45a81674 authored by neis's avatar neis Committed by Commit bot

[debugger] Don't leak holes from generator arguments.

This is a quick fix for the hole leaking from generators via the debugger's frame
inspection feature: when collecting the arguments, convert each hole to undefined.
In the long term, we probably want to remember and restore the actual arguments
rather than pushing these dummy arguments on each resume.

BUG=v8:5164

Review-Url: https://codereview.chromium.org/2122923003
Cr-Commit-Position: refs/heads/master@{#37544}
parent 7614362b
......@@ -874,7 +874,16 @@ Handle<Object> GetFunctionArguments(Isolate* isolate,
// Copy the parameters to the arguments object.
DCHECK(array->length() == length);
for (int i = 0; i < length; i++) array->set(i, frame->GetParameter(i));
for (int i = 0; i < length; i++) {
Object* value = frame->GetParameter(i);
if (value->IsTheHole(isolate)) {
// Generators currently use holes as dummy arguments when resuming. We
// must not leak those.
DCHECK(IsResumableFunction(function->shared()->kind()));
value = isolate->heap()->undefined_value();
}
array->set(i, value);
}
arguments->set_elements(*array);
// Return the freshly allocated arguments object.
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Flags: --expose-debug-as debug
var failure = null;
var args;
function listener(event, exec_state, event_data, data) {
if (event != debug.Debug.DebugEvent.Break) return;
try {
args = exec_state.frame(0).evaluate('arguments').value();
} catch (e) {
failure = e;
}
}
debug.Debug.setListener(listener);
function* gen(a, b) {
debugger;
yield a;
yield b;
}
var foo = gen(1, 2);
foo.next()
assertEquals(2, args.length);
assertEquals(undefined, args[0]);
assertEquals(undefined, args[1]);
foo.next()
assertEquals(2, args.length);
assertEquals(undefined, args[0]);
assertEquals(undefined, args[1]);
foo.next()
assertEquals(2, args.length);
assertEquals(undefined, args[0]);
assertEquals(undefined, args[1]);
assertNull(failure);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment