zirias@
Developer
- Thread Starter
- #26
Well, in my "debug" build config, I add
So, when I'm looking for leaks, I use valgrind. It's an awesome tool overall and has other helpful checkers as well, e.g. I checked my threading code with its
-fsanitize=address
to both CFLAGS and LDFLAGS. This enables clang's runtime memory analyzer, which is quite nice and catches many addressing errors, but unfortunately, its leak checker is not supported on FreeBSD So, when I'm looking for leaks, I use valgrind. It's an awesome tool overall and has other helpful checkers as well, e.g. I checked my threading code with its
helgrind
module (and found quite a few bugs to fix). Interestingly, helgrind still has a complaint when I'm initially starting up my threads and I really can't match it to anything in my code, so my guess now is it's something in FreeBSD's threading lib that's ok but not whitelisted in valgrind's ignore list yet… at least the address it complains about looks like it's in the text segment
Code:
==20001== ---Thread-Announcement------------------------------------------
==20001==
==20001== Thread #3 was created
==20001== at 0x49E139A: thr_new (in /lib/libc.so.7)
==20001== by 0x488D4A4: pthread_create (in /lib/libthr.so.3)
==20001== by 0x4855374: ??? (in /usr/local/libexec/valgrind/vgpreload_helgrind-amd64-freebsd.so)
==20001== by 0x2179D1: ThreadPool_init (threadpool.c:295)
==20001== by 0x212561: dmain (main.c:30)
==20001== by 0x21250D: main (main.c:69)
==20001==
==20001== ---Thread-Announcement------------------------------------------
==20001==
==20001== Thread #2 was created
==20001== at 0x49E139A: thr_new (in /lib/libc.so.7)
==20001== by 0x488D4A4: pthread_create (in /lib/libthr.so.3)
==20001== by 0x4855374: ??? (in /usr/local/libexec/valgrind/vgpreload_helgrind-amd64-freebsd.so)
==20001== by 0x2179D1: ThreadPool_init (threadpool.c:295)
==20001== by 0x212561: dmain (main.c:30)
==20001== by 0x21250D: main (main.c:69)
==20001==
==20001== ----------------------------------------------------------------
==20001==
==20001== Possible data race during read of size 8 at 0x4860CD0 by thread #3
==20001== Locks held: none
==20001== at 0x485E8C7: ??? (in /usr/local/libexec/valgrind/vgpreload_helgrind-amd64-freebsd.so)
==20001== by 0x488D82A: ??? (in /lib/libthr.so.3)
==20001==
==20001== This conflicts with a previous write of size 8 by thread #2
==20001== Locks held: none
==20001== at 0x4006A6D: ??? (in /libexec/ld-elf.so.1)
==20001== by 0x400A472: ??? (in /libexec/ld-elf.so.1)
==20001== by 0x40063EC: ??? (in /libexec/ld-elf.so.1)
==20001== by 0x485E8CB: ??? (in /usr/local/libexec/valgrind/vgpreload_helgrind-amd64-freebsd.so)
==20001== by 0x488D82A: ??? (in /lib/libthr.so.3)
==20001== Address 0x4860cd0 is in a rw- mapped file /usr/local/libexec/valgrind/vgpreload_helgrind-amd64-freebsd.so segment