Re: MALLOC_STATS [was: Clang sanitizer support]
Otto Moerbeek wrote: > yeah, MALLOC_STATS is not well maintained... What's the relation between the MALLOC_STATS code currently in -stable, and the code in your mdump [0] project? Are you experimenting with different approaches? BTW, thanks for your work on this. 0: https://github.com/omoerbeek/mdump
Re: MALLOC_STATS [was: Clang sanitizer support]
Omar Polo wrote: > not tried, but compiles :) Your patch made it compile for me too. With that change I was able to run through the steps in https://www.drijf.net/malloc/ and detect memory leaks! Thank you. What's the process to get your change applied to -current? Should it be submitted to the tech@ list?
Re: MALLOC_STATS [was: Clang sanitizer support]
Omar Polo wrote: > There's a built-in mechanisms to check for memory leaks: > > https://www.drijf.net/malloc/ > > don't know if it still applies, I tried only once and was like a couple > of years ago (if not more). Thanks for the tip, Omar. I just tried compiling malloc.c with MALLOC_STATS defined, but I got a compiler error: clang -O2 -pipe -g -Wimplicit -I/usr/src/lib/libc/include -I/usr/src/lib/libc/hidden \ -D__LIBC__ -Werror-implicit-function-declaration -include namespace.h \ -Werror=deprecated-declarations -DAPIWARN -DYP -I/usr/src/lib/libc/yp\ -I/usr/src/lib/libc -I/usr/src/lib/libc/gdtoa \ -I/usr/src/lib/libc/arch/amd64/gdtoa -DINFNAN_CHECK -DMULTIPLE_THREADS \ -DNO_FENV_H -DUSE_LOCALE -I/usr/src/lib/libc -I/usr/src/lib/libc/citrus \ -DRESOLVSORT -DFLOATING_POINT -DPRINTF_WIDE_CHAR -DSCANF_WIDE_CHAR -DFUTEX -MD \ -MP -c /usr/src/lib/libc/stdlib/malloc.c -o malloc.o /usr/src/lib/libc/stdlib/malloc.c:1613:14: error: use of undeclared identifier 'd' STATS_SUB(d->malloc_used, roldsz - rnewsz); ^ 1 error generated. Malloc source version: $OpenBSD: malloc.c,v 1.270 2021/04/09 06:05:21 otto Exp $ System: 6.9 stable
Re: MALLOC_STATS [was: Clang sanitizer support]
On Fri, Jul 23, 2021 at 11:54:38AM -0500, Joe Nelson wrote: > Otto Moerbeek wrote: > > yeah, MALLOC_STATS is not well maintained... > > What's the relation between the MALLOC_STATS code currently in -stable, > and the code in your mdump [0] project? Are you experimenting with > different approaches? > > BTW, thanks for your work on this. > > 0: https://github.com/omoerbeek/mdump This was an experiment, it's not in a state that is suitable for inclusion into OpenBSD base due to various isues and depedencies on external stuff. -Otto
Re: MALLOC_STATS [was: Clang sanitizer support]
I'll take care. Joe Nelson schreef op 23 juli 2021 18:36:04 CEST: >Omar Polo wrote: >> not tried, but compiles :) > >Your patch made it compile for me too. With that change I was able to >run through the steps in https://www.drijf.net/malloc/ and detect >memory >leaks! Thank you. > >What's the process to get your change applied to -current? Should it be >submitted to the tech@ list? -- Verstuurd vanaf mijn Android apparaat met K-9 Mail. Excuseer mijn beknoptheid.
Re: MALLOC_STATS [was: Clang sanitizer support]
On Fri, Jul 23, 2021 at 06:02:08PM +0200, Omar Polo wrote: > > Joe Nelson writes: > > > Omar Polo wrote: > >> There's a built-in mechanisms to check for memory leaks: > >> > >>https://www.drijf.net/malloc/ > >> > >> don't know if it still applies, I tried only once and was like a couple > >> of years ago (if not more). > > > > Thanks for the tip, Omar. I just tried compiling malloc.c with MALLOC_STATS > > defined, but I got a compiler error: > > > > clang -O2 -pipe -g -Wimplicit -I/usr/src/lib/libc/include > > -I/usr/src/lib/libc/hidden \ > > -D__LIBC__ -Werror-implicit-function-declaration -include > > namespace.h \ > > -Werror=deprecated-declarations -DAPIWARN -DYP > > -I/usr/src/lib/libc/yp\ > > -I/usr/src/lib/libc -I/usr/src/lib/libc/gdtoa > > \ > > -I/usr/src/lib/libc/arch/amd64/gdtoa -DINFNAN_CHECK > > -DMULTIPLE_THREADS \ > > -DNO_FENV_H -DUSE_LOCALE -I/usr/src/lib/libc > > -I/usr/src/lib/libc/citrus \ > > -DRESOLVSORT -DFLOATING_POINT -DPRINTF_WIDE_CHAR -DSCANF_WIDE_CHAR > > -DFUTEX -MD \ > > -MP -c /usr/src/lib/libc/stdlib/malloc.c -o malloc.o > > > > /usr/src/lib/libc/stdlib/malloc.c:1613:14: error: use of undeclared > > identifier 'd' > > > > STATS_SUB(d->malloc_used, roldsz - rnewsz); > > ^ > > 1 error generated. > > > > Malloc source version: > > $OpenBSD: malloc.c,v 1.270 2021/04/09 06:05:21 otto Exp $ > > System: > > 6.9 stable > > that seems to be a typo? > > not tried, but compiles :) yeah, MALLOC_STATS is not well maintained... -Otto > > Index: malloc.c > === > RCS file: /home/cvs/src/lib/libc/stdlib/malloc.c,v > retrieving revision 1.270 > diff -u -p -r1.270 malloc.c > --- malloc.c 9 Apr 2021 06:05:21 - 1.270 > +++ malloc.c 23 Jul 2021 16:01:26 - > @@ -1610,7 +1610,7 @@ orealloc(struct dir_info **argpool, void > } > if (munmap((char *)r->p + rnewsz, roldsz - rnewsz)) > wrterror(pool, "munmap %p", (char *)r->p + > rnewsz); > - STATS_SUB(d->malloc_used, roldsz - rnewsz); > + STATS_SUB(pool->malloc_used, roldsz - rnewsz); > r->size = gnewsz; > if (MALLOC_MOVE_COND(gnewsz)) { > void *pp = MALLOC_MOVE(r->p, gnewsz);
Re: MALLOC_STATS [was: Clang sanitizer support]
Joe Nelson writes: > Omar Polo wrote: >> There's a built-in mechanisms to check for memory leaks: >> >> https://www.drijf.net/malloc/ >> >> don't know if it still applies, I tried only once and was like a couple >> of years ago (if not more). > > Thanks for the tip, Omar. I just tried compiling malloc.c with MALLOC_STATS > defined, but I got a compiler error: > > clang -O2 -pipe -g -Wimplicit -I/usr/src/lib/libc/include > -I/usr/src/lib/libc/hidden \ > -D__LIBC__ -Werror-implicit-function-declaration -include > namespace.h \ > -Werror=deprecated-declarations -DAPIWARN -DYP > -I/usr/src/lib/libc/yp\ > -I/usr/src/lib/libc -I/usr/src/lib/libc/gdtoa > \ > -I/usr/src/lib/libc/arch/amd64/gdtoa -DINFNAN_CHECK > -DMULTIPLE_THREADS \ > -DNO_FENV_H -DUSE_LOCALE -I/usr/src/lib/libc > -I/usr/src/lib/libc/citrus \ > -DRESOLVSORT -DFLOATING_POINT -DPRINTF_WIDE_CHAR -DSCANF_WIDE_CHAR > -DFUTEX -MD \ > -MP -c /usr/src/lib/libc/stdlib/malloc.c -o malloc.o > > /usr/src/lib/libc/stdlib/malloc.c:1613:14: error: use of undeclared > identifier 'd' > > STATS_SUB(d->malloc_used, roldsz - rnewsz); > ^ > 1 error generated. > > Malloc source version: > $OpenBSD: malloc.c,v 1.270 2021/04/09 06:05:21 otto Exp $ > System: > 6.9 stable that seems to be a typo? not tried, but compiles :) Index: malloc.c === RCS file: /home/cvs/src/lib/libc/stdlib/malloc.c,v retrieving revision 1.270 diff -u -p -r1.270 malloc.c --- malloc.c9 Apr 2021 06:05:21 - 1.270 +++ malloc.c23 Jul 2021 16:01:26 - @@ -1610,7 +1610,7 @@ orealloc(struct dir_info **argpool, void } if (munmap((char *)r->p + rnewsz, roldsz - rnewsz)) wrterror(pool, "munmap %p", (char *)r->p + rnewsz); - STATS_SUB(d->malloc_used, roldsz - rnewsz); + STATS_SUB(pool->malloc_used, roldsz - rnewsz); r->size = gnewsz; if (MALLOC_MOVE_COND(gnewsz)) { void *pp = MALLOC_MOVE(r->p, gnewsz);
Re: Clang sanitizer support
On Fri, Jan 8, 2021, at 5:40 PM, Joe Nelson wrote: > Hi all, I'd like to use Clang's AddressSanitizer and ThreadSanitizer > on my OpenBSD development machine. Following up on this, looks like MALLOC_OPTIONS can help me detect use-after-free and double free errors. What I'm missing is a way to detect memory leaks in my programs. Any tips?
Re: Clang sanitizer support
Joe Nelson writes: > On Fri, Jan 8, 2021, at 5:40 PM, Joe Nelson wrote: >> Hi all, I'd like to use Clang's AddressSanitizer and ThreadSanitizer >> on my OpenBSD development machine. > > Following up on this, looks like MALLOC_OPTIONS can help me detect > use-after-free and double free errors. What I'm missing is a way to > detect memory leaks in my programs. Any tips? There's a built-in mechanisms to check for memory leaks: https://www.drijf.net/malloc/ don't know if it still applies, I tried only once and was like a couple of years ago (if not more). HTH
Clang sanitizer support
Hi all, I'd like to use Clang's AddressSanitizer and ThreadSanitizer on my OpenBSD development machine. However, the Clang 10 documentation lists OpenBSD support for only the UndefinedBehaviorSanitizer. Does anyone know how hard it would be to port them? Are they absent because nobody really cares about them, or is it because of a significant technical challenge to get them on OpenBSD? Also, are there alternatives to these sanitizers? Valgrind? Running clang on another OS in vmm(4)? I tried the valgrind package but it segfaulted immediately when I ran it early last year. OS support for sanitizers, as reported by the docs: AddressSanitizer * Android ARM * FreeBSD i386/x86_64 (tested on FreeBSD 11-current) * Linux i386/x86_64 (tested on Ubuntu 12.04) * NetBSD i386/x86_64 * Windows 8.1+ (i386/x86_64) * iOS Simulator * macOS 10.7 - 10.11 (i386/x86_64) ThreadSanitizer * Android aarch64, x86_64 * Darwin arm64, x86_64 * FreeBSD * Linux aarch64, x86_64, powerpc64, powerpc64le * NetBSD MemorySanitizer * FreeBSD * Linux * NetBSD UndefinedBehaviorSanitizer * Android * FreeBSD * Linux * NetBSD * OpenBSD * Windows * macOS