Pergunta

My code:

#include <v8.h>
#include <v8-debug.h>
#include <iostream>
#include <string>
#include <assert.h>

using namespace std;
using namespace v8;

static Local<Value> execJsScript(const std::string& jsCode) {
    Local<String> source = String::NewFromUtf8(Isolate::GetCurrent(), jsCode.c_str());
    Local<v8::Script> script = Script::Compile(source);
    assert(!script.IsEmpty());
    return script->Run();
}

void test_js_DebugBreak() {
    cout << "V8 version: " << v8::V8::GetVersion() << endl;

    auto isolate = Isolate::New();
    Isolate::Scope isolateScope(isolate);
    HandleScope handleScope(isolate);
    Handle<Context> context = Context::New(isolate);
    Context::Scope contextScope(context);
    auto globalObj = context->Global();

    v8::Debug::EnableAgent("test", 5858, true);
    v8::Debug::DebugBreak(isolate);

    // I get this error here:
    // # Fatal error in ..\..\src\compiler.cc, line 274
    // # CHECK(feedback_vector_->length() == length) failed
    execJsScript(
        "function foo(f) { f(); };"
        "function enqueueMicrotask(callback) {"
        "   foo(wrapped);"
        "   function wrapped() {"
        "       callback();"
        "   }"
        "};"
        "enqueueMicrotask(function() {"
        "   throw new Error('fooerr');"
        "});"
    );
}

Now, when you execute this, you need to attach with a JS debugger, e.g. with node-inspector. It will break as expected at the first JS expression. When you click 'continue' in the debugger, you get the fatal error.

Am I doing something wrong? Or is this a bug in V8? This is V8 3.25.8.

(I also asked in the mailing-list here.)

Foi útil?

Solução

From mailing-list here from Michael Stanton:

Hi Albert, This is a bug in V8 (my bad), and has been fixed in V8 3.25.12. Thanks, --Michael Stanton --V8

I tried 3.25.14 and it works.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top