Skip to content

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

Merged
MarshallOfSound merged 1 commit intomasterfrom
ctx-bridge-leak
Feb 5, 2021
Merged

fix: clean up base::LinkedList in context_bridge::ObjectCache#27630
MarshallOfSound merged 1 commit intomasterfrom
ctx-bridge-leak

Conversation

@MarshallOfSound
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

release-clerk bot commented Feb 5, 2021

Release Notes Persisted

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

@trop
Copy link
Copy Markdown
Contributor

trop bot commented Feb 5, 2021

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

@trop
Copy link
Copy Markdown
Contributor

trop bot commented Feb 5, 2021

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

@trop
Copy link
Copy Markdown
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