-
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: properly manage timer in cares ChannelWrap #14634
Conversation
This fixes a bug introduced in 727b291 where code managing the `uv_timer_t` for a `ChannelWrap` instance was left unchanged, when it should have changed the lifetime of the handle to being tied to the `ChannelWrap` instance’s lifetime. Fixes: nodejs#14599 Ref: nodejs#14518
CI: https://ci.nodejs.org/job/node-test-commit/11555/ (edit: green except infra failure) It would be cool to have this in 8.3.0, this fixes a real crash. edit: I won’t be here for most of the weekend, please feel free to fix any change requests yourself |
Is it possible to add a test? |
@mscdex I don’t think that would be any more or less reliable than the existing failing test. Also, this isn’t about the |
Given the frequency of crashes in CI on test-async-wrap-getasyncid, it would be great to fast-track this. But of course, first it needs some reviews... 📟 @bnoordhuis @trevnorris @indutny |
+1 to fast track after it gets a review from the aforementioned |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with minor nits.
ares_destroy(channel_); | ||
CleanupTimer(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double newline here, please.
src/cares_wrap.cc
Outdated
|
||
uv_close(reinterpret_cast<uv_handle_t*>(timer_handle_), | ||
[](uv_handle_t* handle) { | ||
delete reinterpret_cast<uv_timer_t*>(handle); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not absolutely necessary, but doing handle->data = NULL
prior to this may help in the future.
New CI: https://ci.nodejs.org/job/node-test-commit/11568/ |
src/cares_wrap.cc
Outdated
|
||
uv_close(reinterpret_cast<uv_handle_t*>(timer_handle_), | ||
[](uv_handle_t* handle) { | ||
handle->data = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yikes, nullptr
😉 Sorry!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I'm doing this "blind" on the GitHub GUI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. But IMHO why don't we use CARE's own timeout
?
@XadillaX As far as I can tell, c-ares is not involved in actually creating timers in any way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo nits.
src/cares_wrap.cc
Outdated
|
||
|
||
void ChannelWrap::CleanupTimer() { | ||
if (!timer_handle_) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (timer_handle_ == nullptr) return;
src/cares_wrap.cc
Outdated
|
||
uv_close(reinterpret_cast<uv_handle_t*>(timer_handle_), | ||
[](uv_handle_t* handle) { | ||
handle->data = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dead store; the memory is deleted immediately afterwards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Landed in 41a0dfc |
This fixes a bug introduced in 727b291 where code managing the `uv_timer_t` for a `ChannelWrap` instance was left unchanged, when it should have changed the lifetime of the handle to being tied to the `ChannelWrap` instance’s lifetime. Fixes: #14599 Ref: #14518 PR-URL: #14634 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
This fixes a bug introduced in 727b291 where code managing the `uv_timer_t` for a `ChannelWrap` instance was left unchanged, when it should have changed the lifetime of the handle to being tied to the `ChannelWrap` instance’s lifetime. Fixes: #14599 Ref: #14518 PR-URL: #14634 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
This fixes a bug introduced in 727b291 where code managing the
uv_timer_t
for aChannelWrap
instance was left unchanged, when it should have changed the lifetime of the handle to being tied to theChannelWrap
instance’s lifetime.Fixes: #14599
Ref: #14518
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
src/cares_wrap