From nobody Sun Jan 2 00:28:51 2022 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 711BA191779A for ; Sun, 2 Jan 2022 00:28:53 +0000 (UTC) (envelope-from ricky@rickysquid.org) Received: from mail.rickysquid.org (mail.rickysquid.org [104.168.201.163]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4JRKVr328Nz3nND; Sun, 2 Jan 2022 00:28:52 +0000 (UTC) (envelope-from ricky@rickysquid.org) Received: by mail.rickysquid.org (Postfix, from userid 1000) id 8878A40A14; Sun, 2 Jan 2022 00:28:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rickysquid.org; s=default; t=1641083331; bh=y9HWEL7LUtgL7KqvmwM9WwzRrKH+uhMWI6NN2g0rnQs=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=TT2Bb8jhHe0ux1WwJ6GMsG6B0/CIG9qz+XwxKTsm7QRZtzwS5S1L0dItCzHemgKKy KZND0w8WGkcVj8tyVIBSaBfT3WNlyNVaBaO8srXrP+QxLtlbWj31UjWv23+eP8q602 pj9L8ZQrXS6EsRXVnP8umMzR/91XLYLIVm4ifz+eXboxzeQqKbBNoB12t/o9sjFyxu TKMePO4ux8s/tMiVPIwcylq0LB/daDpjybTnXCe5YRmFqia9H9yUyuaaTksCD5j2BH 6F+dSHTcAorB9ZqMz81qxC1QQXiQxGtnRJ8v4knYk2i7ssTau7LB7UP3H8BeMIVP7E hpS+HeGN7staA== Date: Sun, 2 Jan 2022 00:28:51 +0000 From: rickygee To: freebsd-hackers@freebsd.org Cc: Shawn Webb , Luoqi Chen Subject: Re: leak sanitizer support Message-ID: <20220102002851.GA32472@rickysquid.org> List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211230201614.z4bsknfgdde7ufwu@mutt-hbsd> User-Agent: Mutt/1.9.4 (2018-02-28) X-Rspamd-Queue-Id: 4JRKVr328Nz3nND X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=rickysquid.org header.s=default header.b=TT2Bb8jh; dmarc=pass (policy=none) header.from=rickysquid.org; spf=pass (mx1.freebsd.org: domain of ricky@rickysquid.org designates 104.168.201.163 as permitted sender) smtp.mailfrom=ricky@rickysquid.org X-Spamd-Result: default: False [-3.91 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.94)[-0.944]; R_DKIM_ALLOW(-0.20)[rickysquid.org:s=default]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; R_SPF_ALLOW(-0.20)[+mx:c]; NEURAL_HAM_LONG(-0.99)[-0.991]; MIME_GOOD(-0.10)[text/plain]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[rickysquid.org:+]; DMARC_POLICY_ALLOW(-0.50)[rickysquid.org,none]; NEURAL_HAM_SHORT(-0.97)[-0.974]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:54290, ipnet:104.168.128.0/17, country:US]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] X-ThisMailContainsUnwantedMimeParts: N Hey Luoqi & Shawn, This is really cool - I have been testing on -CURRENT, and just needed to change one or two teeny little things and lsan is working in my hokey trivial examples anyway. Only changes so far were matching the method signatures in the derived SuspendedThreadsListFreeBSD class, to match its parent (actually the only sig so far needed amending was GetRegistersAndSP, where second param is now more complex type than before). Anyway here is a remote with the patch applied and my tiny little amendments: https://github.com/emgullufsen/freebsd.git example from testing follows - create leaky code, compile, and run) //CREATE LEAKY CODE - HOKEY EXAMPLE FROM clang ASAN webpage root@dougBSD14-vm:~/mem-leaky # cat leaky.c #include void *p; int main() { p = malloc(7); p = 0; return 0; } //COMPILE root@dougBSD14-vm:~/mem-leaky # clang -fsanitize=address -o leaky leaky.c //RUN root@dougBSD14-vm:~/mem-leaky # ASAN_OPTIONS=detect_leaks=1:verbosity=3 ./leaky [cut output] ================================================================= ==3753==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+0x2be638) #2 0x2373df in _start /usr/src/lib/csu/amd64/crt1_c.c:73:7 #3 0x8002e4007 () SUMMARY: AddressSanitizer: 7 byte(s) leaked in 1 allocation(s). //END OF TESTING EXAMPLE So I have only barely tested this and will continue with more involved tests, but anyway wanted to shoot this out - thanks! -Eric (or ricky, whichevs)