-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Conversation
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
CI: https://ci.nodejs.org/job/node-test-pull-request/29024/ (:white_check_mark:) |
Landed in f938cbd |
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: #31605 PR-URL: #31696 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
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: #31605 PR-URL: #31696 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
@addaleax if this is something that should be in |
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 PR-URL: nodejs#31696 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
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: #31605 PR-URL: #31696 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
@targos … this seems to have ended up on v12.x-staging before the v12.16.3 release, but not in the release itself. It fixes a segfault that is now occurring with v12.16.3 – is there anything I could have done differently here to prevent that? (I do know that I kind of dropped the ball on backporting this, but as you noticed, that was only necessary because other commits hadn’t landed yet, so I don’t think it would have made a difference?) |
@addaleax this wasn't on v12.x-staging before the release. I just updated the branch right after it.
I think the most reliable way would have been to label the original PR as backport-requested with a message indicating that it had to land with this one. I'm definitely open to other ideas. The real issue is that we don't have a documented and easy way to express relations between pull requests. |
@targos Yeah, I’d be a fan of having something more specific than |
a555be2 re-assigned
async_.data
to indicate successor failure of the constructor. As the
HandleWrap
implementationuses that field to access the
HandleWrap
instance from thelibuv handle, this introduced two issues:
MessagePort*
→void*
→HandleWrap*
would be valid.HandleWrap::OnClose()
function fail with anullptr
dereference if the constructor did fail.In particular, the second issue made
test/parallel/test-worker-cleanexit-with-moduleload.js
crash atleast 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 bettererror messages for this type of issue in the future.
Refs: #31605
Example failure: https://ci.nodejs.org/job/node-test-commit-linux-containered/17944/nodes=ubuntu1804_sharedlibs_openssl111_x64/testReport/junit/(root)/test/parallel_test_worker_cleanexit_with_moduleload/
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes