Added rudimentary leak detection
Added rudimentary support for leak detection. When memory::tracker_enabled is true, an alloc_tracker object (see alloctracker.{cc,hh}) object keeps track of still-living memory allocations and the call chain that led to each. Using a new command in gdb, "osv leak show", a developer can analyze the remaining allocations, with the aim of finding memory leaks (noticing that memory leaks often result in repeptitive allocations from the same call chain). This implementation is a good start (and already found 8 leaks in our code), but it's far from being perfect. It severely slows down the workload, the analysis in gdb is not yet friendly enough (requiring manual inspection to look for the more serious leaks), and the backtrace() implementation also appears to be fragile: In more than one occasion, we noticed a yet-unexplained crash when backtrace() unwinds the stack, calls dl_iterate_hphdr() which throws exception and unwinds the stack again. So this code will probably need more work in the future.
Showing
- build.mak 1 addition, 0 deletionsbuild.mak
- core/alloctracker.cc 87 additions, 0 deletionscore/alloctracker.cc
- core/mempool.cc 32 additions, 4 deletionscore/mempool.cc
- include/alloctracker.hh 47 additions, 0 deletionsinclude/alloctracker.hh
- scripts/loader.py 110 additions, 0 deletionsscripts/loader.py
core/alloctracker.cc
0 → 100644
include/alloctracker.hh
0 → 100644
Please register or sign in to comment