8000 fix: clean up base::LinkedList in context_bridge::ObjectCache by MarshallOfSound · Pull Request #27630 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: clean up base::LinkedList in context_bridge::ObjectCache #27630

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

Merged
merged 1 commit into from
Feb 5, 2021

Conversation

MarshallOfSound
Copy link
Member

base::LinkedList does not delete its members on destruction. We need to manually ensure the linkedlist is empty when the ObjectCache is destroyed.

Fixes #27039

Notes: Fixed memory leak when sending non-primitives over the context bridge

base::LinkedList does not delete its members on destruction. We need to
manually ensure the linkedlist is empty when the ObjectCache is
destroyed.

Fixes #27039

Notes: Fixed memory leak when sending non-primitives over the context
bridge
@nornagon nornagon added the semver/patch backwards-compatible bug fixes label Feb 4, 2021
delete node;
}
}
}
Copy link
Member
@ckerr ckerr Feb 5, 2021

Choose a reason for hiding this comment

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

This is a little larger scope, but -- what is the benefit of using base::LinkedList here instead of std::list, which is simpler / doesn't require a ObjectCachePairNode / doesn't have these gotchas?

According to the docs, the main reason to use base::LinkedList are for performance reasons of (1) removal is O(1) rather than O(n), and (2) insertion with base::LinkedList never requires heap allocations. But removal never called except in the destructor, and the items we insert are heap-allocated ObjectCachePairNodes, so do either of those advantages apply here?

If we use a simpler container here, this destructor paragraph would go away entirely as unnecessary

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree in general, I want to land this fix then I'll follow it up to see if we can remove our usage of LinkedList. I can't remember exactly why we used it originally, but this code has been through several refactors and it's possible our usage of LinkedList is no longer required.

@MarshallOfSound MarshallOfSound merged commit b6a91ef into master Feb 5, 2021
@release-clerk
Copy link
release-clerk bot commented Feb 5, 2021

Release Notes Persisted

Fixed memory leak when sending non-primitives over the context bridge

@trop
Copy link
Contributor
trop bot commented Feb 5, 2021

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

@trop
Copy link
Contributor
trop bot commented Feb 5, 2021

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

@trop
Copy link
Contributor
trop bot commented Feb 5, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-pr 🌱 PR opened recently semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Memory leak when passing IPC events over contextBridge
4 participants
0