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

Detect bad WeakHashMap usages where values reference keys #2537

Open
pyricau opened this issue Jun 22, 2023 · 0 comments
Open

Detect bad WeakHashMap usages where values reference keys #2537

pyricau opened this issue Jun 22, 2023 · 0 comments

Comments

@pyricau
Copy link
Member

pyricau commented Jun 22, 2023

Not sure if this should show up in a leakcanary report or be a separate tool. Maybe in Shark CLI.

If doing this as part of the normal heap breadth first traversal, we could note for each path whether they're through a WeakHashMap and what the key was. Then as we expand that path, we check if any new reference to be enqueued is the key. If yes, it's a bad WeakHashMap. Maybe tag the key reference as a "leak"? From that point forward that path should likely be marked as not interesting for looking up bad weak hash maps.

The general idea here, as with all things leakcanary, is figuring out how we can add this without doing significantly more runtime work (e.g. doing several traversals would be bad)

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

No branches or pull requests

1 participant