Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: do not unnecessarily re-assign uv handle data #31696

Closed
wants to merge 1 commit into from

Commits on Feb 8, 2020

  1. src: do not unnecessarily re-assign uv handle data

    a555be2 re-assigned `async_.data` to indicate success
    or failure of the constructor. As the `HandleWrap` implementation
    uses that field to access the `HandleWrap` instance from the
    libuv handle, this introduced two issues:
    
    - It implicitly assumed that casting
      `MessagePort*` → `void*` → `HandleWrap*` would be valid.
    - It made the `HandleWrap::OnClose()` function fail with a
      `nullptr` dereference if the constructor did fail.
    
    In particular, the second issue made
    test/parallel/test-worker-cleanexit-with-moduleload.js` crash at
    least once in CI.
    
    Since re-assigning `async_.data` isn’t actually necessary here
    (only a leftover from earlier versions of that commit), fix this by
    using a local variable instead, and add a `CHECK` that provides better
    error messages for this type of issue in the future.
    
    Refs: nodejs#31605
    addaleax committed Feb 8, 2020
    Copy the full SHA
    3339e8b View commit details
    Browse the repository at this point in the history