Skip to content

Fatal Error when using async wrap APIs #43

Closed
@mike-kaufman

Description

@mike-kaufman

Hi -

The program below causes a crash in node (both mac OS w/ node 5.6 & Win Server 2012 R2 with node 5.9).

'use strict';

var asyncWrap = process.binding('async_wrap');

function setupHooks() {
    asyncWrap.disable();

    asyncWrap.setupHooks(
        function init() {
            asyncWrap.disable();
             console.log('hello from init');
             asyncWrap.enable();
        },
        function before() {
        },
        function after() {
        },
        function destroy() {
        });

    asyncWrap.enable();
}

function doSomethingAsync() {

    // comment out line below to prevent crash
    console.log('setting timeout');

    setTimeout(function t1() {
        console.log('timeout fired');
    }, 1000);
}

// uncomment line below to prevent crash
//doSomethingAsync();
setupHooks();
doSomethingAsync();

The Fatal Error is coming from async-wrap-inl.h, lines 57-58.
The exception seems to be getting set in deps/v8/src/ic/ic.cc, lines 654-656, as the passed-in object is undefined.

The stack of the above call (on windows) is the following:

node.exe!v8::internal::LoadIC::Load(v8::internal::Handlev8::internal::Object object, v8::internal::Handlev8::internal::Name name) Line 680 C++
node.exe!v8::internal::__RT_impl_Runtime_LoadIC_Miss(v8::internal::Arguments args, v8::internal::Isolate * isolate) Line 2389 C++
node.exe!v8::internal::Runtime_LoadIC_Miss(int args_length, v8::internal::Object * * args_object, v8::internal::Isolate * isolate) Line 2371 C++
000001bcc860b61f() Unknown
000002f100000004() Unknown
-- many similar frames omitted--

Any help/suggestions appreciated. It's odd that the crash is prevented by calling doSomethingAsync() at least once before calling setupHooks() and doSomethingAsync() a second time. Also, crash is prevented by removing the first console.log statement in doSomethingAsync().

Thanks,

Mike

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions