cloudflare / wirefilter

An execution engine for Wireshark-like filters
https://blog.cloudflare.com/building-fast-interpreters-in-rust/
MIT License
958 stars 85 forks source link

Memory Leak Detected on Adding Function to Scheme #71

Open veeshi opened 3 years ago

veeshi commented 3 years ago

Using cargo-valgrind on a project using wirefilter shows a memory leak using Scheme::add_function.

Valgrind output is:

       Error leaked 2.3 kiB in 1 block
        Info at malloc
             at alloc::alloc::alloc (alloc.rs:86)
             at hashbrown::raw::inner::RawTable<T>::new_uninitialized (mod.rs:411)
             at hashbrown::raw::inner::RawTable<T>::fallible_with_capacity (mod.rs:440)
             at hashbrown::raw::inner::RawTable<T>::resize (mod.rs:897)
             at hashbrown::raw::inner::RawTable<T>::reserve_rehash (mod.rs:778)
             at hashbrown::raw::inner::RawTable<T>::reserve (mod.rs:731)
             at hashbrown::raw::inner::RawTable<T>::insert (mod.rs:950)
             at indexmap::map::core::IndexMapCore<K,V>::push (core.rs:214)
             at indexmap::map::core::VacantEntry<K,V>::insert (core.rs:630)
             at wirefilter::scheme::Scheme::add_function (scheme.rs:579)

The exact line that seems to cause the leak is: https://github.com/cloudflare/wirefilter/blob/2334ab150abd803a555b1541a7e44891b7f5cc60/engine/src/scheme.rs#L579

marmeladema commented 3 years ago

Hello and thank you for the bug report!

Could you provide a minimal reproducible code and instructions so that we can investigate? That would be really helpful.