Re: leak sanitizer support

From: rickygee <ricky_at_rickysquid.org>
Date: Sun, 02 Jan 2022 21:01:56 UTC
On Sun, Jan 02, 2022 at 07:35:06PM +0000, Eric Gullufsen wrote:
> Awesome sounds great - will test with your new diff & module files posted &
> report back here in a few - thanks!
> 
> On Sun, Jan 02, 2022 at 09:53:06AM -0800, Luoqi Chen wrote:
> > locking issue and also to cleanup some unused code, would you mind trying
> > out the new version? I've updated the diff files.
> > 
> > -luoqi
> 

Hey Luoqi,

Dang you rock - I applied your updated patch against -current (commit
642f77be1d), and everything went swimmingly in initial testing:

//GRABBED PATCH & APPLIED & BUILT/INSTALLED libclang_rt libs
https://people.freebsd.org/~luoqi/lsan/

//TWIST SYSCTL KNOBS (PIE & ASLR)
# sysctl kern.elf64.aslr.pie_enable=0
# sysctl kern.elf64.aslr.enable=0

//COMPILE
# clang -fsanitize=address -g -o leaky3 leaky.c

/* leaky.c */
#include<stdlib.h>

void *p;

int main() {
        p = malloc(7);
        p = 0;
        return 0;
}

//RUN
# ASAN_OPTIONS=detect_leaks=1:verbosity=3 ./leaky3

[output cut]
=================================================================
==785==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 7 byte(s) in 1 object(s) allocated from:
    #0 0x28fcdd in malloc
/usr/src/contrib/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:129:3
    #1 0x2be638 in main /root/mem-leaky/leaky.c:6:6
    #2 0x2373df in _start /usr/src/lib/csu/amd64/crt1_c.c:73:7
    #3 0x8002e4007  (<unknown module>)

SUMMARY: AddressSanitizer: 7 byte(s) leaked in 1 allocation(s).

//END TESTING 

Sweet! I'm not much of a c++ person but I am stoked to read up a bit more and
see how you made this work - it is super cool from what I can glean so far -
learning times for me - thanks!

-Eric