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

refactor: add a wrapper for wrangling uv handles. #25332

Merged
merged 4 commits into from Sep 14, 2020

Conversation

ckerr
Copy link
Member

@ckerr ckerr commented Sep 5, 2020

Description of Change

Part 1 of a fix for #25248, #22069.

Fixes #24965. (h/t @jkleinsc for spotting the connection)

This PR wraps the uv_async_t objects owned by NodeBindings and ElectronBindings inside a new UvHandle wrapper class which handles uv_handle_ts' specific rules about destruction:

[uv_close()] MUST be called on each handle before memory is released. Moreover, the memory can only be released in close_cb or after it has returned.

The UvHandle wrapper class handles this close-delete twostep so that client code doesn't have to think about it. Failure to finish closing before freeing is what caused the uv_walk() crash in #25248.

CC @codebytere

Checklist

Release Notes

Notes: Fixed resource leak in worker threads.

Part 1 of a fix for #25248, #22069.

Place the uv_asyncs owned by NodeBindings, ElectronBindings inside a new
UvHandle wrapper class which manages uv_handles' need for their closed()
callback to be invoked before the handles' memory can be freed.
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Sep 5, 2020
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Sep 6, 2020
@zcbenz zcbenz merged commit 70e3aa0 into master Sep 14, 2020
@release-clerk
Copy link

release-clerk bot commented Sep 14, 2020

Release Notes Persisted

Fixed resource leak in worker threads.

@zcbenz zcbenz deleted the ckerr/master/managed-uv-handles branch September 14, 2020 00:53
mlaurencin pushed a commit to mlaurencin/electron that referenced this pull request Sep 16, 2020
* refactor: add a wrapper for wrangling uv handles.

Part 1 of a fix for electron#25248, electron#22069.

Place the uv_asyncs owned by NodeBindings, ElectronBindings inside a new
UvHandle wrapper class which manages uv_handles' need for their closed()
callback to be invoked before the handles' memory can be freed.

* chore: make lint happy

* refactor: use DCHECK_EQ() instead of DCHECK()

* refactor: fix oops
@codebytere
Copy link
Member

/trop run backport-to 11-x-y,10-x-y

@trop
Copy link
Contributor

trop bot commented Sep 28, 2020

The backport process for this PR has been manually initiated -
sending your commits to "11-x-y"!

@trop
Copy link
Contributor

trop bot commented Sep 28, 2020

The backport process for this PR has been manually initiated -
sending your commits to "10-x-y"!

@trop
Copy link
Contributor

trop bot commented Sep 28, 2020

I have automatically backported this PR to "11-x-y", please check out #25661

@trop
Copy link
Contributor

trop bot commented Sep 28, 2020

I have automatically backported this PR to "10-x-y", please check out #25662

@codebytere
Copy link
Member

/trop run backport-to 9-x-y

@trop
Copy link
Contributor

trop bot commented Sep 28, 2020

The backport process for this PR has been manually initiated -
sending your commits to "9-x-y"!

@trop
Copy link
Contributor

trop bot commented Sep 28, 2020

I have automatically backported this PR to "9-x-y", please check out #25663

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Web worker memory is not released when webworker is terminated
4 participants