You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While running benchmark tests for sodg.rs issue #232, i observed that memory usage kept growing until the process exhausted available RAM. After investigation, the root cause turned out to be in emap.
The ignored regression test drops_values already documents the intended behavior and still fails without the fix, confirming the problem.
Important
The current Drop implementation on Map<V> only deallocates the raw buffer and never walks through occupied nodes to run the destructors of the stored values, so every V that owns resources (files, reference-counted pointers, etc.) is leaked when the map is dropped.
Impact
User code that stores RAII types (e.g., Rc, file handles, network sockets) in the map will leak those resources, breaking invariants and potentially causing use-after-free bugs in dependent code.
Because the regression test is #[ignore], the leak can reappear unnoticed in future releases.
Reproduction (conceptual)
Create let mut map = Map::with_capacity(1);.
Insert an Rc into key 0.
Drop the map and observe that Rc::strong_count is still 2 instead of 1 (captured in the ignored drops_values test).
Expectation
Dropping the Map must drop every Some(V) stored in its nodes before deallocating the backing buffer, so all contained values run their destructors exactly once.
Proposed direction
Update Drop to iterate over occupied nodes, move out each Option<V>, and drop the values before finally calling dealloc.
Audit insert_unchecked, remove_unchecked, and retain for similar drop-handling gaps once the main fix is in place.
Re-enable the drops_values regression test to prevent regressions.
While running benchmark tests for sodg.rs issue #232, i observed that memory usage kept growing until the process exhausted available RAM. After investigation, the root cause turned out to be in emap.
Important
The current
Dropimplementation onMap<V>only deallocates the raw buffer and never walks through occupied nodes to run the destructors of the stored values, so everyVthat owns resources (files, reference-counted pointers, etc.) is leaked when the map is dropped.Impact
Rc, file handles, network sockets) in the map will leak those resources, breaking invariants and potentially causing use-after-free bugs in dependent code.#[ignore], the leak can reappear unnoticed in future releases.Reproduction (conceptual)
let mut map = Map::with_capacity(1);.Rcinto key0.Rc::strong_countis still2instead of1(captured in the ignoreddrops_valuestest).Expectation
Dropping the
Mapmust drop everySome(V)stored in its nodes before deallocating the backing buffer, so all contained values run their destructors exactly once.Proposed direction
Dropto iterate over occupied nodes, move out eachOption<V>, and drop the values before finally callingdealloc.insert_unchecked,remove_unchecked, andretainfor similar drop-handling gaps once the main fix is in place.drops_valuesregression test to prevent regressions.