Skip to content

napi error reporting not thread safe #219

Closed

Description

@stuartcampbell

Original reporter: FreddieAkeroyd

NXIReportError and NXpData are held as global variables in napi.c. So changing the error reporting (NXMSetError) in one thread affects all threads.

We see occasional crashes of the JVM. The Java binding stores thread information in NXpData. If that is overwritten in another thread and an error occurs in the first thread the JNI code tries to throw an exception in the wrong thread. At least I think this is what is happening. Now that I have come up with that theory I can more easily test it.

But I am pretty sure the implementation is broken (for all bindings using napi.c).
Please correct me if I am wrong.

Activity

  1. stuartcampbell commented on May 6, 2014

    @stuartcampbell
    MemberAuthor

    Original reporter: zjttoefs

    (In [1423]) refs #210 #219

    work around threading issue in c api by getting environment dynamically
    simplify error reporting

  2. stuartcampbell commented on May 6, 2014

    @stuartcampbell
    MemberAuthor

    Original reporter: zjttoefs

    (In [1542]) allow setting of error reporting in thread local storage so that
    multiple threads can have their own error reporting
    refs #219

  3. stuartcampbell commented on May 6, 2014

    @stuartcampbell
    MemberAuthor

    Original reporter: zjttoefs

    (In [1543]) use threaded version of error handling setters in Java
    refs #219

  4. stuartcampbell commented on May 6, 2014

    @stuartcampbell
    MemberAuthor

    Original reporter: zjttoefs

    (In [1546]) use Disable and Enable ErrorReporting so that threaded versions are respected
    refs #219

  5. stuartcampbell commented on May 6, 2014

    @stuartcampbell
    MemberAuthor

    Original reporter: zjttoefs

    (In [1548]) create new error reporting function that only takes a message as parameter
    and use that throughout the api
    refs #219

  6. stuartcampbell commented on May 6, 2014

    @stuartcampbell
    MemberAuthor

    Original reporter: zjttoefs

    (In [1552]) Error reporting may have failed due to memory corruption or whatever
    but was masked by threading problems. If we get a fresh class reference
    every time we want to throw an error that helps. refs #219

  7. stuartcampbell commented on May 6, 2014

    @stuartcampbell
    MemberAuthor

    Original reporter: zjttoefs

    (In [1553]) check for thread local storage
    MacOS X doesn't have it (this way)
    refs #219

  8. stuartcampbell commented on May 6, 2014

    @stuartcampbell
    MemberAuthor

    Original reporter: zjttoefs

    (In [1556]) remove DEBUG define left in there
    refs #219

  9. stuartcampbell commented on May 6, 2014

    @stuartcampbell
    MemberAuthor

    Original reporter: zjttoefs

    (In [1557]) fix backwards logic the issued the waring when everything was fine
    refs #219

  10. stuartcampbell commented on May 6, 2014

    @stuartcampbell
    MemberAuthor

    Original reporter: zjttoefs

    (In [1562]) for additional safety bring back the detection of jvm
    refs #219

  11. stuartcampbell commented on May 6, 2014

    @stuartcampbell
    MemberAuthor

    Original reporter: zjttoefs

    (In [1567]) changes to fix the threading problems in the error reporting
    refs #219

  12. stuartcampbell commented on May 6, 2014

    @stuartcampbell
    MemberAuthor

    Original reporter: zjttoefs

    (In [1598]) changes to fix the threading problems in the error reporting
    refs #219

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ Proxy