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

memory leak in slog_scope #255

Open
mimoo opened this issue Feb 14, 2020 · 1 comment
Open

memory leak in slog_scope #255

mimoo opened this issue Feb 14, 2020 · 1 comment
Labels
P-low Priority: Low slog-scope crate: slog-scope

Comments

@mimoo
Copy link

mimoo commented Feb 14, 2020

Running valgrind on a program I have, I obtain a lot of these:

==4175714== 16 bytes in 1 blocks are possibly lost in loss record 24 of 103
==4175714==    at 0x4C29DAF: malloc (vg_replace_malloc.c:309)
==4175714==    by 0x1198DEB: alloc::alloc::alloc (alloc.rs:81)
==4175714==    by 0x1198D5B: alloc::alloc::exchange_malloc (alloc.rs:203)
==4175714==    by 0x119783C: alloc::sync::Arc<T>::new (sync.rs:302)
==4175714==    by 0x11960B6: slog::OwnedKVList::root (lib.rs:3426)
==4175714==    by 0x119618E: slog::Logger<D>::root (lib.rs:1125)
==4175714==    by 0x119433E: __static_ref_initialize (lib.rs:110)
==4175714==    by 0x119433E: core::ops::function::FnOnce::call_once (function.rs:232)
==4175714==    by 0x119271A: lazy_static::lazy::Lazy<T>::get::{{closure}} (inline_lazy.rs:31)
==4175714==    by 0x1198737: std::sync::once::Once::call_once::{{closure}} (once.rs:264)
==4175714==    by 0x1799E70: std::sync::once::Once::call_inner (once.rs:417)
==4175714==    by 0x11986B2: std::sync::once::Once::call_once (once.rs:264)                                                                                              ==4175714==    by 0x119BAA8: get<arc_swap::ArcSwapAny<alloc::sync::Arc<slog::Logger<alloc::sync::Arc<SendSyncRefUnwindSafeDrain>>>, arc_swap::gen_lock::Global>,fn() -> a
rc_swap::ArcSwapAny<alloc::sync::Arc<slog::Logger<alloc::sync::Arc<SendSyncRefUnwindSafeDrain>>>, arc_swap::gen_lock::Global>> (inline_lazy.rs:30)
==4175714==    by 0x119BAA8: __stability (<::lazy_static::__lazy_static_internal macros>:16)
==4175714==    by 0x119BAA8: <slog_scope::GLOBAL_LOGGER as core::ops::deref::Deref>::deref (<::lazy_static::__lazy_static_internal macros>:18)

way to repro:

git clone --depth 1 https://github.com/libra/libra.git
cd libra/testsuite/libra-fuzzer
mkdir -p fuzz/corpus/addmission_control
echo "CswBKskB0njtjZhgowd2SjEB3IHegKQ9IUQRjELOcD0Xov3K9CE2F6aKwZmkBwMAAAAZAAAAtlYH3Ag+23KMY6B1tqBHEbBAUaxMScfWwZcOhVJS1/oSHKpxHc03UIdPSvkksDFODSAAAADGx885lPdOFj7vzuiGRP/v4VeM/Vq8GhWEXEPzFwaT8kAAAAB2ovix102nyik07zRXRqYO6/hovSjhn+p2MEyxnWD4hB6CAgHZH3x5JJ1zOjQUt+3Dd5vGHuoE6U7Ft7tBpXsF" | base64 -D > fuzz/corpus/admission_control/0705ebd76487a545fbde086c56f678bc996db1c3
cargo build --bin investigate
valgrind --leak-check=full ../../target/debug/investigate  -i fuzz/corpus/admission_control/0705ebd76487a545fbde086c56f678bc996db1c3
@dpc
Copy link
Collaborator

dpc commented Feb 14, 2020

lazy_static never frees stuff inside it by design. I'm not sure if there's more to it.

@Techcable Techcable added slog-scope crate: slog-scope P-low Priority: Low labels Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-low Priority: Low slog-scope crate: slog-scope
Projects
None yet
Development

No branches or pull requests

3 participants