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

smol::run() leak? #7

Closed
dbuch opened this issue Apr 19, 2020 · 1 comment
Closed

smol::run() leak? #7

dbuch opened this issue Apr 19, 2020 · 1 comment

Comments

@dbuch
Copy link

dbuch commented Apr 19, 2020

So i tested a simple program with valgrind.

use anyhow::Result;

fn main() -> Result<()> {
    smol::run(async {
        Ok(())
    })
}

While I'm not going to brag about deep knowledge about valgrind

Here is some output from valgrind:

==60440== Memcheck, a memory error detector
==60440== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==60440== Using Valgrind-3.15.0-608cb11914-20190413X and LibVEX; rerun with -h for copyright info
==60440== Command: ./target/debug/smol-playground
==60440== Parent PID: 52069
==60440== 
--60440-- 
--60440-- Valgrind options:
--60440--    --log-file=valgrind-output.txt
--60440--    --track-origins=yes
--60440--    --track-fds=yes
--60440--    --leak-check=full
--60440--    --show-reachable=yes
--60440--    --trace-children=yes
--60440--    --read-var-info=yes
--60440--    -v
--60440-- Contents of /proc/version:
--60440--   Linux version 5.6.4-arch1-1 (linux@archlinux) (gcc version 9.3.0 (Arch Linux 9.3.0-1)) #1 SMP PREEMPT Mon, 13 Apr 2020 12:21:19 +0000
--60440-- 
--60440-- Arch and hwcaps: AMD64, LittleEndian, amd64-cx16-lzcnt-rdtscp-sse3-ssse3-avx-avx2-bmi-f16c-rdrand
--60440-- Page sizes: currently 4096, max supported 4096
--60440-- Valgrind library directory: /usr/lib/valgrind
--60440-- Reading syms from /home/dbuch/dev/rust/smol-playground/target/debug/smol-playground
--60440-- warning: DiCfSI 0x108000 .. 0x108164 outside mapped rx segments (NONE)
--60440-- warning: DiCfSI 0x108000 .. 0x108299 outside mapped rx segments (NONE)
--60440-- warning: DiCfSI 0x108000 .. 0x10813d outside mapped rx segments (NONE)
--60440-- warning: DiCfSI 0x108000 .. 0x10802d outside mapped rx segments (NONE)
--60440-- warning: DiCfSI 0x108000 .. 0x10821f outside mapped rx segments (NONE)
--60440-- warning: DiCfSI 0x108000 .. 0x108001 outside mapped rx segments (NONE)
--60440-- warning: DiCfSI 0x108002 .. 0x108003 outside mapped rx segments (NONE)
--60440-- warning: DiCfSI 0x108004 .. 0x108005 outside mapped rx segments (NONE)
--60440-- warning: DiCfSI 0x108006 .. 0x108006 outside mapped rx segments (NONE)
--60440-- warning: DiCfSI 0x108007 .. 0x108265 outside mapped rx segments (NONE)

parse DIE(readdwarf3.c:3123): confused by:
 <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
     DW_AT_producer    : (indirect string, offset: 0x0): clang LLVM (rustc version 1.42.0 (b8cedc004 2020-03-09))	
     DW_AT_language    : 28	
     DW_AT_name        : (indirect string, offset: 0x39): src/main.rs	
     DW_AT_stmt_list   : 0	
     DW_AT_comp_dir    : (indirect string, offset: 0x45): /home/dbuch/dev/rust/smol-playground	
     DW_AT_???         : 1	
     DW_AT_low_pc      : 0x0	
     DW_AT_ranges      : 48	
parse_type_DIE:
--60440-- WARNING: Serious error when reading debug info
--60440-- When reading debug info from /home/dbuch/dev/rust/smol-playground/target/debug/smol-playground:
--60440-- confused by the above DIE
--60440-- Reading syms from /usr/lib/ld-2.31.so
--60440-- Reading syms from /usr/lib/valgrind/memcheck-amd64-linux
--60440--    object doesn't have a dynamic symbol table
--60440-- warning: addVar: unknown size (s)
--60440-- warning: addVar: unknown size (s)
--60440-- warning: addVar: unknown size (s)
--60440-- warning: addVar: unknown size (s)
--60440-- warning: addVar: unknown size (s)
--60440-- warning: addVar: unknown size (s)
--60440-- warning: addVar: unknown size (s)
--60440-- warning: addVar: unknown size (s)
--60440-- warning: addVar: unknown size (s)
--60440-- warning: addVar: unknown size (s)
--60440-- Scheduler: using generic scheduler lock implementation.
--60440-- Reading suppressions file: /usr/lib/valgrind/default.supp
==60440== embedded gdbserver: reading from /tmp/vgdb-pipe-from-vgdb-to-60440-by-dbuch-on-???
==60440== embedded gdbserver: writing to   /tmp/vgdb-pipe-to-vgdb-from-60440-by-dbuch-on-???
==60440== embedded gdbserver: shared mem   /tmp/vgdb-pipe-shared-mem-vgdb-60440-by-dbuch-on-???
==60440== 
==60440== TO CONTROL THIS PROCESS USING vgdb (which you probably
==60440== don't want to do, unless you know exactly what you're doing,
==60440== or are doing some strange experiment):
==60440==   /usr/lib/valgrind/../../bin/vgdb --pid=60440 ...command...
==60440== 
==60440== TO DEBUG THIS PROCESS USING GDB: start GDB like this
==60440==   /path/to/gdb ./target/debug/smol-playground
==60440== and then give GDB the following command
==60440==   target remote | /usr/lib/valgrind/../../bin/vgdb --pid=60440
==60440== --pid is optional if only one valgrind process is running
==60440== 
--60440-- REDIR: 0x40212b0 (ld-linux-x86-64.so.2:strlen) redirected to 0x580c7532 (vgPlain_amd64_linux_REDIR_FOR_strlen)
--60440-- REDIR: 0x4021080 (ld-linux-x86-64.so.2:index) redirected to 0x580c754c (vgPlain_amd64_linux_REDIR_FOR_index)
--60440-- Reading syms from /usr/lib/valgrind/vgpreload_core-amd64-linux.so
--60440-- Reading syms from /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so
==60440== WARNING: new redirection conflicts with existing -- ignoring it
--60440--     old: 0x040212b0 (strlen              ) R-> (0000.0) 0x580c7532 vgPlain_amd64_linux_REDIR_FOR_strlen
--60440--     new: 0x040212b0 (strlen              ) R-> (2007.0) 0x0483cda0 strlen
--60440-- REDIR: 0x401da90 (ld-linux-x86-64.so.2:strcmp) redirected to 0x483dc90 (strcmp)
--60440-- REDIR: 0x4021810 (ld-linux-x86-64.so.2:mempcpy) redirected to 0x4841670 (mempcpy)
--60440-- Reading syms from /usr/lib/libdl-2.31.so
--60440--    object doesn't have a symbol table
--60440-- Reading syms from /usr/lib/librt-2.31.so
--60440--    object doesn't have a symbol table
--60440-- Reading syms from /usr/lib/libpthread-2.31.so
--60440-- Reading syms from /usr/lib/libgcc_s.so.1
--60440-- Reading syms from /usr/lib/libc-2.31.so
--60440-- REDIR: 0x495cc40 (libc.so.6:memmove) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495bfc0 (libc.so.6:strncpy) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495cf70 (libc.so.6:strcasecmp) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495b8e0 (libc.so.6:strcat) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495c020 (libc.so.6:rindex) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495e310 (libc.so.6:rawmemchr) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x49767f0 (libc.so.6:wmemchr) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x4976330 (libc.so.6:wcscmp) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495cda0 (libc.so.6:mempcpy) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495cbd0 (libc.so.6:bcmp) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495bf50 (libc.so.6:strncmp) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495b990 (libc.so.6:strcmp) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495cd00 (libc.so.6:memset) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x49762f0 (libc.so.6:wcschr) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495beb0 (libc.so.6:strnlen) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495ba70 (libc.so.6:strcspn) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495cfc0 (libc.so.6:strncasecmp) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495ba10 (libc.so.6:strcpy) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495d110 (libc.so.6:memcpy@@GLIBC_2.14) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x4977a40 (libc.so.6:wcsnlen) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x4976370 (libc.so.6:wcscpy) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495c060 (libc.so.6:strpbrk) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495b940 (libc.so.6:index) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495be70 (libc.so.6:strlen) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x4962750 (libc.so.6:memrchr) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495d010 (libc.so.6:strcasecmp_l) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495cb90 (libc.so.6:memchr) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x4976440 (libc.so.6:wcslen) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495c320 (libc.so.6:strspn) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495cf10 (libc.so.6:stpncpy) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495ceb0 (libc.so.6:stpcpy) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495e350 (libc.so.6:strchrnul) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x495d060 (libc.so.6:strncasecmp_l) redirected to 0x482f1c0 (_vgnU_ifunc_wrapper)
--60440-- REDIR: 0x4a2e000 (libc.so.6:__strrchr_avx2) redirected to 0x483c7b0 (rindex)
--60440-- REDIR: 0x4957e00 (libc.so.6:malloc) redirected to 0x4839710 (malloc)
--60440-- REDIR: 0x495c7d0 (libc.so.6:__GI_strstr) redirected to 0x48418c0 (__strstr_sse2)
--60440-- REDIR: 0x4a2a030 (libc.so.6:__memchr_avx2) redirected to 0x483dd10 (memchr)
--60440-- REDIR: 0x49586b0 (libc.so.6:realloc) redirected to 0x483bd00 (realloc)
--60440-- REDIR: 0x4a311e0 (libc.so.6:__memcpy_avx_unaligned_erms) redirected to 0x4840690 (memmove)
--60440-- REDIR: 0x4a2a300 (libc.so.6:__rawmemchr_avx2) redirected to 0x4841210 (rawmemchr)
--60440-- REDIR: 0x4958440 (libc.so.6:free) redirected to 0x483a940 (free)
--60440-- REDIR: 0x4a31660 (libc.so.6:__memset_avx2_unaligned_erms) redirected to 0x4840580 (memset)
--60440-- REDIR: 0x4958b80 (libc.so.6:calloc) redirected to 0x483bab0 (calloc)
--60440-- REDIR: 0x49598c0 (libc.so.6:posix_memalign) redirected to 0x483bfa0 (posix_memalign)
==60440== 
==60440== FILE DESCRIPTORS: 7 open at exit.
==60440== Open AF_UNIX socket 8: <unknown>
==60440==    at 0x49CDA7E: socketpair (in /usr/lib/libc-2.31.so)
==60440==    by 0x17396B: socket2::sys::Socket::pair (unix.rs:202)
==60440==    by 0x172F08: socket2::socket::Socket::pair (socket.rs:82)
==60440==    by 0x12B13C: smol::pipe (lib.rs:1873)
==60440==    by 0x12A740: smol::SelfPipe::new (lib.rs:1818)
==60440==    by 0x12A420: smol::IoEvent::new (lib.rs:1786)
==60440==    by 0x13548D: smol::WorkStealingExecutor::get::EXECUTOR::{{closure}} (lib.rs:801)
==60440==    by 0x157734: core::ops::function::FnOnce::call_once (function.rs:232)
==60440==    by 0x157803: core::ops::function::FnOnce::call_once (function.rs:232)
==60440==    by 0x137235: once_cell::sync::Lazy<T,F>::force::{{closure}} (lib.rs:910)
==60440==    by 0x137466: once_cell::sync::OnceCell<T>::get_or_init::{{closure}} (lib.rs:763)
==60440==    by 0x15F84C: once_cell::imp::OnceCell<T>::initialize::{{closure}} (imp_std.rs:96)
==60440== 
==60440== Open AF_UNIX socket 7: <unknown>
==60440==    at 0x49CDA7E: socketpair (in /usr/lib/libc-2.31.so)
==60440==    by 0x17396B: socket2::sys::Socket::pair (unix.rs:202)
==60440==    by 0x172F08: socket2::socket::Socket::pair (socket.rs:82)
==60440==    by 0x12B13C: smol::pipe (lib.rs:1873)
==60440==    by 0x12A740: smol::SelfPipe::new (lib.rs:1818)
==60440==    by 0x12A420: smol::IoEvent::new (lib.rs:1786)
==60440==    by 0x13548D: smol::WorkStealingExecutor::get::EXECUTOR::{{closure}} (lib.rs:801)
==60440==    by 0x157734: core::ops::function::FnOnce::call_once (function.rs:232)
==60440==    by 0x157803: core::ops::function::FnOnce::call_once (function.rs:232)
==60440==    by 0x137235: once_cell::sync::Lazy<T,F>::force::{{closure}} (lib.rs:910)
==60440==    by 0x137466: once_cell::sync::OnceCell<T>::get_or_init::{{closure}} (lib.rs:763)
==60440==    by 0x15F84C: once_cell::imp::OnceCell<T>::initialize::{{closure}} (imp_std.rs:96)
==60440== 
==60440== Open file descriptor 6:
==60440==    at 0x49CCD6B: epoll_create1 (in /usr/lib/libc-2.31.so)
==60440==    by 0x13C76F: nix::sys::epoll::epoll_create1 (epoll.rs:78)
==60440==    by 0x137D5F: smol::sys::Reactor::new (lib.rs:2289)
==60440==    by 0x135E35: smol::Reactor::get::REACTOR::{{closure}} (lib.rs:1088)
==60440==    by 0x157604: core::ops::function::FnOnce::call_once (function.rs:232)
==60440==    by 0x1576E3: core::ops::function::FnOnce::call_once (function.rs:232)
==60440==    by 0x137005: once_cell::sync::Lazy<T,F>::force::{{closure}} (lib.rs:910)
==60440==    by 0x1373FB: once_cell::sync::OnceCell<T>::get_or_init::{{closure}} (lib.rs:763)
==60440==    by 0x15F561: once_cell::imp::OnceCell<T>::initialize::{{closure}} (imp_std.rs:96)
==60440==    by 0x1759AA: once_cell::imp::initialize_inner (imp_std.rs:133)
==60440==    by 0x15F4BD: once_cell::imp::OnceCell<T>::initialize (imp_std.rs:94)
==60440==    by 0x137743: once_cell::sync::OnceCell<T>::get_or_try_init (lib.rs:803)
==60440== 
==60440== Open file descriptor 3: /home/dbuch/dev/rust/smol-playground/valgrind-output.txt
==60440==    <inherited from parent>
==60440== 
==60440== Open file descriptor 2: /dev/pts/4
==60440==    <inherited from parent>
==60440== 
==60440== Open file descriptor 1: /dev/pts/4
==60440==    <inherited from parent>
==60440== 
==60440== Open file descriptor 0: /dev/pts/4
==60440==    <inherited from parent>
==60440== 
==60440== 
==60440== HEAP SUMMARY:
==60440==     in use at exit: 14,908 bytes in 18 blocks
==60440==   total heap usage: 39 allocs, 21 frees, 18,529 bytes allocated
==60440== 
==60440== Searching for pointers to 18 not-freed blocks
==60440== Checked 128,784 bytes
==60440== 
==60440== 4 bytes in 1 blocks are still reachable in loss record 1 of 11
==60440==    at 0x483977F: malloc (vg_replace_malloc.c:309)
==60440==    by 0x13CB3B: alloc::alloc::alloc (alloc.rs:81)
==60440==    by 0x13CAAB: alloc::alloc::exchange_malloc (alloc.rs:203)
==60440==    by 0x136529: smol::Async<T>::new (boxed.rs:174)
==60440==    by 0x12AAFB: smol::SelfPipe::new (lib.rs:1824)
==60440==    by 0x12A420: smol::IoEvent::new (lib.rs:1786)
==60440==    by 0x13548D: smol::WorkStealingExecutor::get::EXECUTOR::{{closure}} (lib.rs:801)
==60440==    by 0x157734: core::ops::function::FnOnce::call_once (function.rs:232)
==60440==    by 0x157803: core::ops::function::FnOnce::call_once (function.rs:232)
==60440==    by 0x137235: once_cell::sync::Lazy<T,F>::force::{{closure}} (lib.rs:910)
==60440==    by 0x137466: once_cell::sync::OnceCell<T>::get_or_init::{{closure}} (lib.rs:763)
==60440==    by 0x15F84C: once_cell::imp::OnceCell<T>::initialize::{{closure}} (imp_std.rs:96)
==60440== 
==60440== 24 bytes in 1 blocks are still reachable in loss record 2 of 11
==60440==    at 0x483977F: malloc (vg_replace_malloc.c:309)
==60440==    by 0x13CB3B: alloc::alloc::alloc (alloc.rs:81)
==60440==    by 0x13C911: <alloc::alloc::Global as core::alloc::Alloc>::alloc (alloc.rs:169)
==60440==    by 0x152706: alloc::raw_vec::RawVec<T,A>::reserve_internal (raw_vec.rs:661)
==60440==    by 0x153E19: alloc::raw_vec::RawVec<T,A>::reserve (raw_vec.rs:485)
==60440==    by 0x155839: alloc::vec::Vec<T>::reserve (vec.rs:493)
==60440==    by 0x15510C: alloc::vec::Vec<T>::push (vec.rs:1166)
==60440==    by 0x12CB09: slab::Slab<T>::insert_at (lib.rs:632)
==60440==    by 0x12CF17: slab::VacantEntry<T>::insert (lib.rs:891)
==60440==    by 0x12809A: smol::WorkStealingExecutor::worker (lib.rs:846)
==60440==    by 0x120F94: smol::run (lib.rs:503)
==60440==    by 0x1252C9: smol_playground::main (main.rs:4)
==60440== 
==60440== 32 bytes in 1 blocks are still reachable in loss record 3 of 11
==60440==    at 0x483BD7B: realloc (vg_replace_malloc.c:836)
==60440==    by 0x13CC0C: alloc::alloc::realloc (alloc.rs:125)
==60440==    by 0x13C9D5: <alloc::alloc::Global as core::alloc::Alloc>::realloc (alloc.rs:184)
==60440==    by 0x1520C2: alloc::raw_vec::RawVec<T,A>::reserve_internal (raw_vec.rs:659)
==60440==    by 0x153C09: alloc::raw_vec::RawVec<T,A>::reserve (raw_vec.rs:485)
==60440==    by 0x155869: alloc::vec::Vec<T>::reserve (vec.rs:493)
==60440==    by 0x15526C: alloc::vec::Vec<T>::push (vec.rs:1166)
==60440==    by 0x12CD5A: slab::Slab<T>::insert_at (lib.rs:632)
==60440==    by 0x12CFA7: slab::VacantEntry<T>::insert (lib.rs:891)
==60440==    by 0x128EF2: smol::Reactor::register (lib.rs:1115)
==60440==    by 0x136417: smol::Async<T>::new (lib.rs:1331)
==60440==    by 0x12AAFB: smol::SelfPipe::new (lib.rs:1824)
==60440== 
==60440== 40 bytes in 1 blocks are still reachable in loss record 4 of 11
==60440==    at 0x483977F: malloc (vg_replace_malloc.c:309)
==60440==    by 0x13CB3B: alloc::alloc::alloc (alloc.rs:81)
==60440==    by 0x13CAAB: alloc::alloc::exchange_malloc (alloc.rs:203)
==60440==    by 0x15B8E7: alloc::sync::Arc<T>::new (sync.rs:302)
==60440==    by 0x12A536: smol::IoEvent::new (lib.rs:1786)
==60440==    by 0x13548D: smol::WorkStealingExecutor::get::EXECUTOR::{{closure}} (lib.rs:801)
==60440==    by 0x157734: core::ops::function::FnOnce::call_once (function.rs:232)
==60440==    by 0x157803: core::ops::function::FnOnce::call_once (function.rs:232)
==60440==    by 0x137235: once_cell::sync::Lazy<T,F>::force::{{closure}} (lib.rs:910)
==60440==    by 0x137466: once_cell::sync::OnceCell<T>::get_or_init::{{closure}} (lib.rs:763)
==60440==    by 0x15F84C: once_cell::imp::OnceCell<T>::initialize::{{closure}} (imp_std.rs:96)
==60440==    by 0x1759AA: once_cell::imp::initialize_inner (imp_std.rs:133)
==60440== 
==60440== 40 bytes in 1 blocks are possibly lost in loss record 5 of 11
==60440==    at 0x483977F: malloc (vg_replace_malloc.c:309)
==60440==    by 0x16CB6B: alloc::alloc::alloc (alloc.rs:81)
==60440==    by 0x16CADB: alloc::alloc::exchange_malloc (alloc.rs:203)
==60440==    by 0x16B94D: std::sync::mutex::Mutex<T>::new (mutex.rs:168)
==60440==    by 0x169FFB: piper::signal::Signal::inner (signal.rs:139)
==60440==    by 0x166983: piper::signal::Signal::notify_one (signal.rs:104)
==60440==    by 0x15ADEA: <piper::lock::LockGuard<T> as core::ops::drop::Drop>::drop (lock.rs:265)
==60440==    by 0x157F8E: core::ptr::drop_in_place (mod.rs:174)
==60440==    by 0x128F39: smol::Reactor::register (lib.rs:1116)
==60440==    by 0x136417: smol::Async<T>::new (lib.rs:1331)
==60440==    by 0x12AAFB: smol::SelfPipe::new (lib.rs:1824)
==60440==    by 0x12A420: smol::IoEvent::new (lib.rs:1786)
==60440== 
==60440== 72 bytes in 1 blocks are possibly lost in loss record 6 of 11
==60440==    at 0x483977F: malloc (vg_replace_malloc.c:309)
==60440==    by 0x16CB6B: alloc::alloc::alloc (alloc.rs:81)
==60440==    by 0x16CADB: alloc::alloc::exchange_malloc (alloc.rs:203)
==60440==    by 0x1695DD: alloc::sync::Arc<T>::new (sync.rs:302)
==60440==    by 0x16A03F: piper::signal::Signal::inner (signal.rs:137)
==60440==    by 0x166983: piper::signal::Signal::notify_one (signal.rs:104)
==60440==    by 0x15ADEA: <piper::lock::LockGuard<T> as core::ops::drop::Drop>::drop (lock.rs:265)
==60440==    by 0x157F8E: core::ptr::drop_in_place (mod.rs:174)
==60440==    by 0x128F39: smol::Reactor::register (lib.rs:1116)
==60440==    by 0x136417: smol::Async<T>::new (lib.rs:1331)
==60440==    by 0x12AAFB: smol::SelfPipe::new (lib.rs:1824)
==60440==    by 0x12A420: smol::IoEvent::new (lib.rs:1786)
==60440== 
==60440== 80 bytes in 1 blocks are still reachable in loss record 7 of 11
==60440==    at 0x483977F: malloc (vg_replace_malloc.c:309)
==60440==    by 0x13CB3B: alloc::alloc::alloc (alloc.rs:81)
==60440==    by 0x13CAAB: alloc::alloc::exchange_malloc (alloc.rs:203)
==60440==    by 0x15B57D: alloc::sync::Arc<T>::new (sync.rs:302)
==60440==    by 0x128D44: smol::Reactor::register (lib.rs:1107)
==60440==    by 0x136417: smol::Async<T>::new (lib.rs:1331)
==60440==    by 0x12AAFB: smol::SelfPipe::new (lib.rs:1824)
==60440==    by 0x12A420: smol::IoEvent::new (lib.rs:1786)
==60440==    by 0x13548D: smol::WorkStealingExecutor::get::EXECUTOR::{{closure}} (lib.rs:801)
==60440==    by 0x157734: core::ops::function::FnOnce::call_once (function.rs:232)
==60440==    by 0x157803: core::ops::function::FnOnce::call_once (function.rs:232)
==60440==    by 0x137235: once_cell::sync::Lazy<T,F>::force::{{closure}} (lib.rs:910)
==60440== 
==60440== 576 bytes in 8 blocks are still reachable in loss record 8 of 11
==60440==    at 0x483977F: malloc (vg_replace_malloc.c:309)
==60440==    by 0x13CB3B: alloc::alloc::alloc (alloc.rs:81)
==60440==    by 0x13CAAB: alloc::alloc::exchange_malloc (alloc.rs:203)
==60440==    by 0x165A5C: std::sync::rwlock::RwLock<T>::new (rwlock.rs:134)
==60440==    by 0x156B8B: crossbeam_utils::sync::sharded_lock::ShardedLock<T>::new::{{closure}} (sharded_lock.rs:104)
==60440==    by 0x1423D0: core::iter::adapters::map_fold::{{closure}} (mod.rs:772)
==60440==    by 0x140DA8: core::iter::traits::iterator::Iterator::fold::ok::{{closure}} (iterator.rs:1900)
==60440==    by 0x12D51A: core::iter::traits::iterator::Iterator::try_fold (iterator.rs:1776)
==60440==    by 0x12D42E: core::iter::traits::iterator::Iterator::fold (iterator.rs:1903)
==60440==    by 0x142A01: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::fold (mod.rs:812)
==60440==    by 0x141F54: core::iter::traits::iterator::Iterator::for_each (iterator.rs:655)
==60440==    by 0x1560B7: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::spec_extend (vec.rs:2054)
==60440== 
==60440== 1,016 bytes in 1 blocks are still reachable in loss record 9 of 11
==60440==    at 0x483977F: malloc (vg_replace_malloc.c:309)
==60440==    by 0x13CB3B: alloc::alloc::alloc (alloc.rs:81)
==60440==    by 0x13CAAB: alloc::alloc::exchange_malloc (alloc.rs:203)
==60440==    by 0x148B8B: crossbeam_deque::Injector<T>::new (boxed.rs:174)
==60440==    by 0x135431: smol::WorkStealingExecutor::get::EXECUTOR::{{closure}} (lib.rs:799)
==60440==    by 0x157734: core::ops::function::FnOnce::call_once (function.rs:232)
==60440==    by 0x157803: core::ops::function::FnOnce::call_once (function.rs:232)
==60440==    by 0x137235: once_cell::sync::Lazy<T,F>::force::{{closure}} (lib.rs:910)
==60440==    by 0x137466: once_cell::sync::OnceCell<T>::get_or_init::{{closure}} (lib.rs:763)
==60440==    by 0x15F84C: once_cell::imp::OnceCell<T>::initialize::{{closure}} (imp_std.rs:96)
==60440==    by 0x1759AA: once_cell::imp::initialize_inner (imp_std.rs:133)
==60440==    by 0x15F3A2: once_cell::imp::OnceCell<T>::initialize (imp_std.rs:94)
==60440== 
==60440== 1,024 bytes in 1 blocks are still reachable in loss record 10 of 11
==60440==    at 0x483BEB8: memalign (vg_replace_malloc.c:908)
==60440==    by 0x483BFCE: posix_memalign (vg_replace_malloc.c:1072)
==60440==    by 0x1AE7A9: __rdl_alloc (alloc.rs:85)
==60440==    by 0x13CB3B: alloc::alloc::alloc (alloc.rs:81)
==60440==    by 0x13C911: <alloc::alloc::Global as core::alloc::Alloc>::alloc (alloc.rs:169)
==60440==    by 0x152DF6: alloc::raw_vec::RawVec<T,A>::reserve_internal (raw_vec.rs:661)
==60440==    by 0x153CB9: alloc::raw_vec::RawVec<T,A>::reserve (raw_vec.rs:485)
==60440==    by 0x1557D9: alloc::vec::Vec<T>::reserve (vec.rs:493)
==60440==    by 0x155FCC: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::spec_extend (vec.rs:2050)
==60440==    by 0x1561F0: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter (vec.rs:2034)
==60440==    by 0x1567DC: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter (vec.rs:1919)
==60440==    by 0x141E74: core::iter::traits::iterator::Iterator::collect (iterator.rs:1558)
==60440== 
==60440== 12,000 bytes in 1 blocks are still reachable in loss record 11 of 11
==60440==    at 0x483977F: malloc (vg_replace_malloc.c:309)
==60440==    by 0x13CB3B: alloc::alloc::alloc (alloc.rs:81)
==60440==    by 0x13C911: <alloc::alloc::Global as core::alloc::Alloc>::alloc (alloc.rs:169)
==60440==    by 0x14FF0D: alloc::raw_vec::RawVec<T,A>::allocate_in (raw_vec.rs:88)
==60440==    by 0x14F855: alloc::raw_vec::RawVec<T>::with_capacity (raw_vec.rs:140)
==60440==    by 0x1548D3: alloc::vec::Vec<T>::with_capacity (vec.rs:355)
==60440==    by 0x161F4D: <T as alloc::vec::SpecFromElem>::from_elem (vec.rs:1733)
==60440==    by 0x155981: alloc::vec::from_elem (vec.rs:1723)
==60440==    by 0x138203: smol::sys::Events::new (lib.rs:2320)
==60440==    by 0x135E97: smol::Reactor::get::REACTOR::{{closure}} (lib.rs:1090)
==60440==    by 0x157604: core::ops::function::FnOnce::call_once (function.rs:232)
==60440==    by 0x1576E3: core::ops::function::FnOnce::call_once (function.rs:232)
==60440== 
==60440== LEAK SUMMARY:
==60440==    definitely lost: 0 bytes in 0 blocks
==60440==    indirectly lost: 0 bytes in 0 blocks
==60440==      possibly lost: 112 bytes in 2 blocks
==60440==    still reachable: 14,796 bytes in 16 blocks
==60440==         suppressed: 0 bytes in 0 blocks
==60440== 
==60440== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
@ghost
Copy link

ghost commented Apr 19, 2020

This is normal. This crate lazily initializes static variables that get allocated on the heap, and there isn't a great way to destroy statics at program exit. Those static should technically live in static memory rather than on the heap, which is why valgrind reports them as leaks.

The same issue was seen in other crates like crossbeam, rayon, parking_lot, and tokio:
crossbeam-rs/crossbeam#110
crossbeam-rs/crossbeam#285
Amanieu/parking_lot#211
tokio-rs/tokio#872

@ghost ghost closed this as completed Apr 19, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant