GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Callback gets crashed on Windows · Issue #199 · node-ffi/node-ffi

Callback gets crashed on Windows #199

New issue
Copy link
New issue
Copy link
Closed
Closed
Callback gets crashed on Windows#199
Copy link

Description

@unbornchikken
unbornchikken
opened on Apr 4, 2015
Issue body actions

Under some unobvious circumstances, libuv's uv_thread_self() gives NULL on Windows. And because of this CallbackInfo::Invoke() thinks that it is running on main node thread:

uv_thread_t self_thread = (uv_thread_t) uv_thread_self();
if (uv_thread_equal(&self_thread, &g_mainthread)) { ...

If uv_thread_self() gives NULL then the above will always true and DispatchToV8 called on the thread that the foreign function uses to call back our callback. :) I'm getting it with my NOOOCL module, where OpenCL event callbacks are invoked on different threads. And of course on an OpenCL thread there isn't a V8 Isolate instance, so WrapPointer method's first line (NanEscapableScope()) crases with an access violation.

In "unobvious circumstances" I mean I am not geting this libuv issue on my work machine (Windows 8.1 x64). On my home machine I am (Windows 7 x64). Reporter of this issue is getting it: unbornchikken/NOOOCL#2 (Windows 8.1). So I made a PR, where there is a workaround, on Windows GetCurrentThreadId() will determine if we're on node thread or not when called back.

Activity

  1. unbornchikken commented on Apr 7, 2015

    @unbornchikken
    unbornchikken
    on Apr 7, 2015
    MemberAuthor
    More actions

    If anyone's suffering from this, I've applied the patch to my ffi-io fork, you can use it instead of ffi till the above PR gets merged.

  2. grushetsky commented on Apr 15, 2015

    @grushetsky
    grushetsky
    on Apr 15, 2015
    More actions

    Looks like I have the same issue. I'm making a call to a function of my custom DLL passing a callback in parameters. This callback is fired on a different thread inside the library and the application just hangs in this case.

    I use ffi module from an Atom Shell (which is based on io.js) application on Windows 8.1 x64.

    The fork you suggested gets the job done. Gábor, thank you very much for the fix!

  3. TooTallNate
    closed this as completedin fc7aaccon Apr 16, 2015
  4. unbornchikken
    added a commit that references this issue on Apr 16, 2015

    test: add case for #199 that covers callback and error propagation on…

    403d821
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.