Wireshark-dev: Re: [Wireshark-dev] Memory leak debugging - current master passes all tests!
On Tue, Jan 29, 2019 at 08:59:30AM +0100, Dario Lombardo wrote:
> > This does not mean that there are no more memory leaks though (we have
> > pretty bad test coverage)
>
> Have you ever tried to compute the coverage with, eg., gcov/lcov? I'm
> working on it but it's still a WIP.
> There are also public platforms (as coveralls) that help keeping track of
> it over time/over history.
I have used a coverage checker (llvm-cov) during development of a single
dissector, but not the whole project. From my notes:
# epan/dissectors/CMakeList.txt after "set_target_properties(dissectors PROPERTIES"
set(COV_FLAGS "-fprofile-instr-generate -fcoverage-mapping")
set(COV_FLAGS "${COV_FLAGS}" PARENT_SCOPE)
set_source_files_properties(packet-wireguard.c PROPERTIES COMPILE_FLAGS "${WERROR_COMMON_FLAGS} ${COV_FLAGS}")
# epan/CMakeLists.txt after "set_target_properties(epan PROPERTIES"
set_target_properties(epan PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS} ${COV_FLAGS}")
# run program and check results with
llvm-profdata merge -sparse default.profraw -o default.profdata
llvm-cov show \
/tmp/wsbuild/epan/dissectors/CMakeFiles/dissectors.dir/packet-wireguard.c.o \
-instr-profile=default.profdata -use-color=1 \
/tmp/wireshark/epan/dissectors/packet-wireguard.c | less -R
Though even without using external tools, a good starting point would be
adding basic tests for everything that uses a UAT. Stig recently fixed
some memleaks in packet-lwm2mtlv.c which were not caught by tests...
because there were none! ;)
On Tue, Jan 29, 2019 at 09:15:50AM -0500, Jeff Morriss wrote:
> Nice info. I had wondered at some points how to run ASAN but not enough to
> do the (probably minimal) research. Could I suggest putting the info in a
> Wiki page? (When I look for info I look in the READMEs and the wiki; I
> rarely search the email archives unless I remember what I was looking for
> being there.)
I think I have found an appropriate place for it here:
https://wiki.wireshark.org/Development/Tips#Debugging_using_AddressSanitizer
https://wiki.wireshark.org/Development/Tips#Running_dumpcap_on_Linux_as_unprivileged_user
Feel free to make more edits as needed :)
--
Kind regards,
Peter Wu
https://lekensteyn.nl