Skip to content

Conversation

@addaleax
Copy link
Member

@addaleax addaleax commented Aug 4, 2017

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

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included (eeeeh … in the form of an existing test that was flaky)
  • commit message follows commit guidelines
Affected core subsystem(s)

src/cares_wrap

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
@addaleax addaleax requested a review from XadillaX August 4, 2017 19:01
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. cares Issues and PRs related to the c-ares dependency or the cares_wrap binding. labels Aug 4, 2017
@addaleax
Copy link
Member Author

addaleax commented Aug 4, 2017

CI: https://ci.nodejs.org/job/node-test-commit/11555/ (edit: green except infra failure)
Stress master: https://ci.nodejs.org/job/node-stress-single-test/1358/ (edit: red, 245/1000 failed)
Stress this PR: https://ci.nodejs.org/job/node-stress-single-test/1359/ (edit: green, 0/1000 failed)

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

@mscdex
Copy link
Contributor

mscdex commented Aug 4, 2017

Is it possible to add a test?

@mscdex mscdex added the timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout. label Aug 4, 2017
@addaleax
Copy link
Member Author

addaleax commented Aug 4, 2017

@mscdex I don’t think that would be any more or less reliable than the existing failing test.

Also, this isn’t about the set* globals/the timers core module that the label is for, so I think that can be removed?

@Trott
Copy link
Member

Trott commented Aug 5, 2017

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

@refack
Copy link
Contributor

refack commented Aug 5, 2017

+1 to fast track after it gets a review from the aforementioned

Copy link
Member

@indutny indutny left a 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();
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double newline here, please.


uv_close(reinterpret_cast<uv_handle_t*>(timer_handle_),
[](uv_handle_t* handle) {
delete reinterpret_cast<uv_timer_t*>(handle);
Copy link
Member

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.

@refack
Copy link
Contributor

refack commented Aug 5, 2017


uv_close(reinterpret_cast<uv_handle_t*>(timer_handle_),
[](uv_handle_t* handle) {
handle->data = NULL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes, nullptr 😉 Sorry!

Copy link
Contributor

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.

@refack
Copy link
Contributor

refack commented Aug 5, 2017

@refack
Copy link
Contributor

refack commented Aug 5, 2017

ARM fail is #14206
So CI & stress are ✔️

Copy link
Contributor

@XadillaX XadillaX left a 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?

Refs: c-ares/c-ares#135 (comment)

@addaleax
Copy link
Member Author

addaleax commented Aug 7, 2017

@XadillaX As far as I can tell, c-ares is not involved in actually creating timers in any way.

Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo nits.



void ChannelWrap::CleanupTimer() {
if (!timer_handle_) return;
Copy link
Member

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;


uv_close(reinterpret_cast<uv_handle_t*>(timer_handle_),
[](uv_handle_t* handle) {
handle->data = nullptr;
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, this was requested by @indutny and added by @refack. If they had any particular reason for that, please speak up, but I’ve removed it again for now.

@addaleax addaleax mentioned this pull request Aug 7, 2017
@addaleax
Copy link
Member Author

addaleax commented Aug 7, 2017

Landed in 41a0dfc

@addaleax addaleax closed this Aug 7, 2017
@addaleax addaleax deleted the cares-fix-timer branch August 7, 2017 11:59
addaleax added a commit that referenced this pull request Aug 7, 2017
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>
addaleax added a commit that referenced this pull request Aug 7, 2017
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>
@MylesBorins MylesBorins added lts-watch-v6.x baking-for-lts PRs that need to wait before landing in a LTS release. labels Aug 16, 2017
@MylesBorins MylesBorins removed the baking-for-lts PRs that need to wait before landing in a LTS release. label Aug 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. cares Issues and PRs related to the c-ares dependency or the cares_wrap binding. timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test/parallel/test-async-wrap-getasyncid.js crashing