Skip to content

EXC_BAD_ACCESS: Environment::GetCurrent returns nullptr in node::EmitAsyncDestroy #27218

Description

@markandrus
  • Version: v10.11.0
  • Platform: macOS
  • Subsystem: async_hooks

Hi, I'm porting my Native Addon from NAN to N-API and I've hit an issue. I have some objects which make use of node-addon-api's Napi::ObjectWrap and Napi::AsyncContext classes; however, I'm raising an issue here, because I'm not sure these are specific to node-addon-api. I actually hit a similar issue with NAN a while back (nodejs/nan#772).

What I see is that the call to Environment::GetCurrent(isolate) in node::EmitAsyncDestroy returns nullptr. I believe that is because this call to isolate->GetCurrentContext() returns nullptr. This results in an EXC_BAD_ACCESS.

You can see how I worked around this issue (starting with Node 9) when using NAN, although 1. it's probably incorrect and 2. it relies on v8 APIs that I don't want to use when porting to N-API.

Is this a bug? Am I doing something wrong? Thanks in advance!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    node-apiIssues and PRs related to Node-API.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions