if (!cp || dash != '-' || colon != ':')
to
if (dash != '-' || colon != ':')
do you agreed?
Agreed. I'll apply this patch.
I found 3 leaks, the biggest is in the
src/ptrace/_UPT_find_proc_info.c:get_unwind_info() function as you
mentioned,
I looked at this some more. The unw_cursor_t keeps track of the previous elf image mapped. Before mapping a new image, it unmaps the previous image, so there is no leak.
But in poc.c:
unw_init_remote(&orig_cursor, as, upt);
curr_cursor = orig_cursor;
This assignment makes the cursor lose track of what was previously mapped. I'll let David comment on if a separate API call is needed to cleanup the cursor or the implementation could unmap the last mmap when the end of call chain is reached.
and there are two other minor leaks in the
src/dwarf/global.c:dwarf_init(), as I said before, these mempools are
never unmapped.
These are by design. I'm not sure you can do much about it, other than unmapping the memory when libunwind is unloaded. This shouldn't be a large chunk of memory and more importantly, it's a one time allocation needed for libunwind to function and hence not a leak.
-Arun