rlei / nonblockinghashmap

Non-blocking hash map in Rust
42 stars 4 forks source link

Leaks and double frees in unsafe code #5

Open rlei opened 5 years ago

rlei commented 5 years ago

Multiple occurrences of leaks and (possible) double frees caused by unmatched Box::into_raw and Box::from_raw calls have be identified in current implementation.

see https://github.com/rlei/nonblockinghashmap/commit/6e6793b0787e633db891738c36e86fcfd059dca0 for an (incomplete) list of leaks.

rlei commented 5 years ago

For example, the summary from valgrind --leak-check=full target/debug/deps/nonblockinghashmap-69f481c86edb5ffd --nocapture test_hashmap_concurrent_rw_no_resize: (with num_keys lowered to 10_000 in test)

==28153== LEAK SUMMARY:
==28153==    definitely lost: 4,000,000 bytes in 250,000 blocks
==28153==    indirectly lost: 7,320,000 bytes in 440,000 blocks
==28153==      possibly lost: 0 bytes in 0 blocks
==28153==    still reachable: 32 bytes in 1 blocks
==28153==         suppressed: 0 bytes in 0 blocks
==28153== Reachable blocks (those to which a pointer was found) are not shown.
rlei commented 5 years ago

Commit https://github.com/rlei/nonblockinghashmap/commit/650d7982fc5932e807e4140a5e760ccbe57c3574 just kicked off the rewriting of the underlying key/value storage.

rlei commented 5 years ago

And https://github.com/rlei/nonblockinghashmap/commit/ed9d9bc0d2db2d79e01865cede819ab8676a2bf0