-
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
async_wrap: close the destroy_ids_idle_handle_ on environment destruction #10385
Conversation
The destroy_ids_idle_handle_ needs to be closed on environment destruction. Not closing the handle leaves a dangling pointer in the used uv loop. This leads to undefined behavior when the uv loop is used after the environment has been destroyed.
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.
Seems okay but I agree that this approach looks a bit like overkill, let’s hear what others think.
A rule of thumb I use is "don't generalize until there are at least two or three instances." In this particular case, I'd just close the idle handle last in the destructor. Aside: am I to infer SAP uses node in their products? It sure is a step up from ABAP. :-) (I spent most of 2004 writing ABAP. I don't hate it, actually.) |
Do not add the destroy_ids_idle_handle_ to a separate handle clenup queue. Call uv_close on the handle directly in the environment destructor.
Good point. I moved the cleanup code completely to the environment destructor. @bnoordhuis You are right, we use node in our products. Your ABAP programming skills are probably better than mine. I have never written a single line of code in ABAP :-) |
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.
Member handle_cleanup_waiting_ must be set to one before the uv_close on destroy_ids_idle_handle_ is called.
The destroy_ids_idle_handle_ needs to be closed on environment destruction. Not closing the handle leaves a dangling pointer in the used uv loop. This leads to undefined behavior when the uv loop is used after the environment has been destroyed. PR-URL: #10385 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
Landed in c7ff96b |
The destroy_ids_idle_handle_ needs to be closed on environment destruction. Not closing the handle leaves a dangling pointer in the used uv loop. This leads to undefined behavior when the uv loop is used after the environment has been destroyed. PR-URL: nodejs#10385 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
The destroy_ids_idle_handle_ needs to be closed on environment destruction. Not closing the handle leaves a dangling pointer in the used uv loop. This leads to undefined behavior when the uv loop is used after the environment has been destroyed. PR-URL: nodejs#10385 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
The destroy_ids_idle_handle_ needs to be closed on environment destruction. Not closing the handle leaves a dangling pointer in the used uv loop. This leads to undefined behavior when the uv loop is used after the environment has been destroyed. PR-URL: nodejs#10385 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
The destroy_ids_idle_handle_ needs to be closed on environment destruction. Not closing the handle leaves a dangling pointer in the used uv loop. This leads to undefined behavior when the uv loop is used after the environment has been destroyed. PR-URL: nodejs#10385 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
@trevnorris should this be backported? Do you want to do a batch update to async_wrap across the LTS lines? |
ping @trevnorris |
ping |
The destroy_ids_idle_handle_ needs to be closed on environment destruction. Not closing the handle leaves a dangling pointer in the used uv loop. This leads to undefined behavior when the uv loop is used after the environment has been destroyed. PR-URL: nodejs#10385 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
backport in #12922 |
The destroy_ids_idle_handle_ needs to be closed on environment destruction. Not closing the handle leaves a dangling pointer in the used uv loop. This leads to undefined behavior when the uv loop is used after the environment has been destroyed. PR-URL: #10385 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
The destroy_ids_idle_handle_ needs to be closed on environment destruction. Not closing the handle leaves a dangling pointer in the used uv loop. This leads to undefined behavior when the uv loop is used after the environment has been destroyed. PR-URL: #10385 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
The destroy_ids_idle_handle_ needs to be closed on environment destruction. Not closing the handle leaves a dangling pointer in the used uv loop. This leads to undefined behavior when the uv loop is used after the environment has been destroyed. PR-URL: nodejs/node#10385 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
async_wrap
Description of change
The
destroy_ids_idle_handle_
is currently not getting closed in the environment destructor. After the environment has been destroyed, the uv loop used by the environment contains a dangling pointer in the handle list which leads to undefined behavior when the loop is still being used.This is currently no issue for the "main" uv loop used by node. However if an embedder creates his own environment this will most likely lead to crashes. By looking at the code in
Environment::Start
it was also not entirely clear for me thatdestroy_ids_idle_handle_
is not added to the handle cleanup queue by intention.The additional delayed cleanup queue may be an overkill since it only contains one handle right now, but it seemed to me that it would be the most generic and verbose approach.