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

Fix leak of underlying data hash count #5

Merged
merged 3 commits into from
Jul 16, 2020

Conversation

ahornby
Copy link
Contributor

@ahornby ahornby commented Jul 15, 2020

The ArcIntern hash() function had to Arc::into_raw without a balancing Arc::from_raw

This PR

  • Adds a test of the count of underlying drop's done to the multithreading test
  • Shows that calling hash was causing not enough drops of underlying data and thus a leak
  • Fixes hash so that it doesn't trigger a leak

This is done by adding an Arc to the test struct and then checking the
Arc's strong_count

Tested with cargo test
underlying object leaks

Tested with cargo test
The call to into_raw was leaking the increase in Arc count from the
clone.

Fix was to add the matching from_raw so the count decreases

Tested with cargo test.  Tests now pass again
@ryzhyk
Copy link
Owner

ryzhyk commented Jul 16, 2020

This is horrible. Thanks for catching the bug and for the fix.

@ryzhyk ryzhyk merged commit 136f960 into ryzhyk:master Jul 16, 2020
ryzhyk added a commit that referenced this pull request Jul 16, 2020
Port memory leak fix (#5) to the 0.1 branch, which is still the most
popular one on crates.io.
@guswynn guswynn mentioned this pull request Jul 16, 2020
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.

2 participants