-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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 of global locks (libevent-2.0.21-stable) #55
Comments
We can add following patches to fix the bug
--------------------------------------------------------------------patch of evutil_rand.c------------------------------------------------------------------
------------------------------------------------------------patch of event.c---------------------------------------------------------------------------------
|
This part is broken:
If someone creates two event_bases, and frees the second one, this will free the global locks. Libevent 2.1 already has a fix for this in the libevent_global_shutdown() function. |
OK, i see, current_base is not a right flag for releasing global locks. |
test code
valgrind --leak-check=full --show-reachable=yes ./a.out
==15543== Memcheck, a memory error detector.
==15543== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al.
==15543== Using LibVEX rev 1658, a library for dynamic binary translation.
==15543== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP.
==15543== Using valgrind-3.2.1, a dynamic binary instrumentation framework.
==15543== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al.
==15543== For more details, rerun with: -v
==15543==
==15543==
==15543== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 1)
==15543== malloc/free: in use at exit: 120 bytes in 3 blocks.
==15543== malloc/free: 14 allocs, 11 frees, 1,776 bytes allocated.
==15543== For counts of detected errors, rerun with: -v
==15543== searching for pointers to 3 not-freed blocks.
==15543== checked 206,968 bytes.
==15543==
==15543== 120 bytes in 3 blocks are still reachable in loss record 1 of 1
==15543== at 0x4A05809: malloc (vg_replace_malloc.c:149)
==15543== by 0x4E61ED1: evthread_posix_lock_alloc (evthread_pthread.c:46)
==15543== by 0x4C2AB37: event_global_setup_locks_ (event.c:2894)
==15543== by 0x4E61CE3: evthread_use_pthreads (evthread_pthread.c:187)
==15543== by 0x400A57: main (in /root/dev/a.out)
==15543==
==15543== LEAK SUMMARY:
==15543== definitely lost: 0 bytes in 0 blocks.
==15543== possibly lost: 0 bytes in 0 blocks.
==15543== still reachable: 120 bytes in 3 blocks.
==15543== suppressed: 0 bytes in 0 blocks.
The text was updated successfully, but these errors were encountered: