NetBSD Problem Report #59189

From wiz@gatalith.at  Mon Mar 17 14:06:37 2025
Return-Path: <wiz@gatalith.at>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 445E21A9239
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 17 Mar 2025 14:06:37 +0000 (UTC)
Message-Id: <20250317140633.2665E3915ED@gatalith.at>
Date: Mon, 17 Mar 2025 15:06:33 +0100 (CET)
From: wiz@gatalith.at
Reply-To: wiz@gatalith.at
To: gnats-bugs@NetBSD.org
Subject: leak sanitizer broken
X-Send-Pr-Version: 3.95

>Number:         59189
>Category:       toolchain
>Synopsis:       leak sanitizer broken
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Mar 17 14:10:00 +0000 2025
>Last-Modified:  Mon Mar 24 07:25:01 +0000 2025
>Originator:     Thomas Klausner
>Release:        NetBSD 10.99.12
>Organization:

>Environment:


Architecture: x86_64
Machine: amd64
>Description:
The leak sanitizer is broken on -current.

On NetBSD 10, the program below (from riastradh) does:

# make lsanthread DBG=-g\ -O2\ -Wall\ -Werror\ -fsanitize=leak LDLIBS=-pthread
cc -g -O2 -Wall -Werror -fsanitize=leak    -o lsanthread lsanthread.c -pthread
# ./lsanthread

=================================================================
==9052==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 2 byte(s) in 2 object(s) allocated from:
    #0 0x75d53c005d27 in __interceptor_malloc /usr/src/external/gpl3/gcc/dist/libsanitizer/lsan/lsan_interceptors.cc:53
    #1 0x400abb in thread /home/wiz/lsanthread.c:14
    #2 0x75d53bc0c89e in pthread__create_tramp /usr/src/lib/libpthread/pthread.c:595

SUMMARY: LeakSanitizer: 2 byte(s) leaked in 2 allocation(s).

while on NetBSD 10.99.12, it does

# make lsanthread DBG=-g\ -O2\ -Wall\ -Werror\ -fsanitize=leak LDLIBS=-pthread
cc -g -O2 -Wall -Werror -fsanitize=leak    -o lsanthread lsanthread.c -pthread
ld: /usr/lib/libm.so.0: warning: warning: reference to compatibility cabs()
ld: /usr/lib/libm.so.0: warning: warning: reference to compatibility cabsf()
# ./lsanthread
zsh: segmentation fault (core dumped)  ./lsanthread

Here's the program:

/*
 * make lsanthread DBG=-g\ -O2\ -Wall\ -Werror\ -fsanitize=leak LDLIBS=-pthread
 */

#include <err.h>
#include <pthread.h>
#include <stdlib.h>

static void *
thread(void *cookie)
{
	void *volatile p;

	p = malloc(1);
	p = NULL;

	return p;
}

int
main(void)
{
	pthread_t t[2];
	void *result;
	unsigned i;
	int error;

	for (i = 0; i < __arraycount(t); i++) {
		error = pthread_create(&t[i], NULL, &thread, NULL);
		if (error)
			errc(1, error, "pthread_create");
	}
	for (i = 0; i < __arraycount(t); i++) {
		error = pthread_join(t[i], &result);
		if (error)
			errc(1, error, "pthread_join");
	}

	return 0;
}

>How-To-Repeat:
See above.
>Fix:
Yes, please, and please add tests so this doesn't break again, unnoticed.

>Audit-Trail:
From: Thomas Klausner <wiz@NetBSD.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: toolchain/59189: leak sanitizer broken
Date: Tue, 18 Mar 2025 16:15:32 +0100

 --Yv63Z8Q90D8MSmcU
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline

 The breakage is not pthread-related, it also causes a segfault with an
 even simpler test case, attached, which on NetBSD 10 prints:

 $ ./lsan
 All is well.

 =================================================================
 ==29831==ERROR: LeakSanitizer: detected memory leaks

 Direct leak of 1 byte(s) in 1 object(s) allocated from:
     #0 0x73aab1405d27 in __interceptor_malloc /usr/src/external/gpl3/gcc/dist/libsanitizer/lsan/lsan_interceptors.cc:53
     #1 0x4009db in main /home/wiz/lsan.c:13
     #2 0x4008fc in ___start /usr/src/lib/csu/common/crt0-common.c:350
     #3 0x7f7f9900baf7  (/usr/libexec/ld.elf_so+0xbaf7)

 SUMMARY: LeakSanitizer: 1 byte(s) leaked in 1 allocation(s).

  Thomas

 --Yv63Z8Q90D8MSmcU
 Content-Type: text/x-c; charset=us-ascii
 Content-Disposition: attachment; filename=lsan.c

 /*
  * make lsan DBG=-g\ -Wall\ -Werror\ -fsanitize=leak
  */

 #include <stdio.h>
 #include <stdlib.h>

 int
 main(void)
 {
 	void *p;

 	p = malloc(1);
 	p = NULL;

 	if (p == NULL) {
 	  printf("All is well.\n");
 	}
 	return 0;
 }

 --Yv63Z8Q90D8MSmcU--

From: Christos Zoulas <christos@zoulas.com>
To: gnats-bugs@netbsd.org
Cc: toolchain-manager@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: toolchain/59189: leak sanitizer broken
Date: Thu, 20 Mar 2025 09:46:40 -0400

 --Apple-Mail=_6B2B9F26-2CF6-49AF-8883-96257DE7A8CE
 Content-Transfer-Encoding: quoted-printable
 Content-Type: text/plain;
 	charset=us-ascii

 So it dies jumping to 0 when trying to call the real ataxit() from =
 __interceptor_atexit() in the call ataxit(cleanup) from crt0.

 (gdb) where
 #0  0x0000000000000000 in ?? ()
 #1  0x00007384ff3f44e2 in __interceptor_atexit (
     f=3Df@entry=3D0x7f7ff73384cf <_rtld_exit>)
     at =
 /usr/src/external/gpl3/gcc/dist/libsanitizer/lsan/lsan_interceptors.cpp:38=
 1
 #2  0x00000000004012e7 in ___start (cleanup=3D0x7f7ff73384cf =
 <_rtld_exit>,=20
     ps_strings=3D0x7f7fff70afe0) at =
 /usr/src/lib/csu/common/crt0-common.c:321
 #3  0x00007f7ff733ef58 in ?? () from /usr/libexec/ld.elf_so
 #4  0x0000000000000001 in ?? ()
 #5  0x00007f7fff70a410 in ?? ()
 #6  0x0000000000000000 in ?? ()
 (gdb) up
 #1  0x00007384ff3f44e2 in __interceptor_atexit (
     f=3Df@entry=3D0x7f7ff73384cf <_rtld_exit>)
     at =
 /usr/src/external/gpl3/gcc/dist/libsanitizer/lsan/lsan_interceptors.cpp:38=
 1
 381       return REAL(__cxa_atexit)((void (*)(void *a))f, 0, 0);
 Current language:  auto
 The current source language is "auto; currently c++".
 (gdb) disassemble
 Dump of assembler code for function __interceptor_atexit(void (*)()):
    0x00007384ff3f44c4 <+0>:     push   %rbp
    0x00007384ff3f44c5 <+1>:     mov    %rsp,%rbp
    0x00007384ff3f44c8 <+4>:     push   %rbx
    0x00007384ff3f44c9 <+5>:     sub    $0x8,%rsp
    0x00007384ff3f44cd <+9>:     mov    %rdi,%rbx
    0x00007384ff3f44d0 <+12>:    call   0x7384ff3f9d53 =
 <_ZN6__lsan19DisableInThisThreadEv>
    0x00007384ff3f44d5 <+17>:    xor    %edx,%edx
    0x00007384ff3f44d7 <+19>:    xor    %esi,%esi
    0x00007384ff3f44d9 <+21>:    mov    %rbx,%rdi
    0x00007384ff3f44dc <+24>:    call   *0x3bb3e(%rip)        # =
 0x7384ff430020 <_ZN14__interception17real___cxa_atexitE>
 =3D> 0x00007384ff3f44e2 <+30>:    mov    %eax,%ebx
    0x00007384ff3f44e4 <+32>:    call   0x7384ff3f9d68 =
 <_ZN6__lsan18EnableInThisThreadEv>
    0x00007384ff3f44e9 <+37>:    mov    %ebx,%eax
    0x00007384ff3f44eb <+39>:    add    $0x8,%rsp
    0x00007384ff3f44ef <+43>:    pop    %rbx
    0x00007384ff3f44f0 <+44>:    pop    %rbp
    0x00007384ff3f44f1 <+45>:    ret
 End of assembler dump.
 (gdb) info reg
 rax            0xffffffffffffffe0  -32
 rbx            0x7f7ff73384cf      140187584922831
 rcx            0x4033b8            4207544
 rdx            0x0                 0
 rsi            0x0                 0
 rdi            0x7f7ff73384cf      140187584922831
 rbp            0x7f7fff709d50      0x7f7fff709d50
 rsp            0x7f7fff709d40      0x7f7fff709d40
 r8             0x10                16
 r9             0x50654             329300
 r10            0x7384ff984438      127015061046328
 r11            0x246               582
 r12            0x7f7fff70afe0      140187723149280
 r13            0x403480            4207744
 r14            0x7f7fff709d98      140187723144600
 r15            0x104aa88           17083016
 rip            0x7384ff3f44e2      0x7384ff3f44e2 =
 <__interceptor_atexit(void (*)())+30>
 eflags         0x10246             [ PF ZF IF RF ]
 cs             0x47                71
 ss             0x3f                63
 ds             0x23                35
 es             0x23                35
 fs             0x0                 0
 gs             0x0                 0
 fs_base        <unavailable>
 gs_base        <unavailable>
 (gdb) print *(char **)(0x7384ff3f44e2+0x3bb3e)
 $1 =3D 0x0

 Something seems to be wrong with the relocation record of ataxit() but =
 it is supposed to work
 because the dynamic linking has finished. Adding -Wl,-z,now does not =
 help either.

 Trying to compile statically does not work at all because we are missing =
 libsanitizer.spec:

 [9:41am] 182>gcc -static -fsanitize=3Dleak -g -O3 lsan.c
 gcc: fatal error: cannot read spec file 'libsanitizer.spec': No such =
 file or directory
 compilation terminated.

 Providing libsanitizer.spec in /usr/lib containing:

 [9:42am] 156#cat /usr/lib/libsanitizer.spec=20
 # This spec file is read by gcc when linking.  It is used to specify the
 # standard libraries we need in order to link with various sanitizer =
 libs.

 *link_libasan: -lrt -lpthread -lm

 *link_libhwasan: -lrt -lpthread -lm

 *link_libtsan: -lrt -lpthread -lm

 *link_libubsan: -lrt -lpthread -lm

 *link_liblsan: -lrt -lpthread -lm

 We get link errors:
 [9:43am] 184>gcc -static -fsanitize=3Dleak -g -O3 lsan.c
 ld: /usr/lib/libpthread.a(libpthread.a.o): in function =
 `__libc_thr_create':
 (.text+0x589e): multiple definition of `pthread_create'; =
 /usr/lib/liblsan.a(lsan_interceptors.o):lsan_interceptors.cpp:(.text+0x35b=
 ): first defined here
 ld: /usr/lib/libpthread.a(libpthread.a.o): in function `pthread_detach':
 (.text+0x6050): multiple definition of `pthread_detach'; =
 /usr/lib/liblsan.a(lsan_interceptors.o):lsan_interceptors.cpp:(.text+0x1b7=
 ): first defined here
 ld: /usr/lib/libpthread.a(libpthread.a.o): in function `pthread_join':
 (.text+0x5e56): multiple definition of `pthread_join'; =
 /usr/lib/liblsan.a(lsan_interceptors.o):lsan_interceptors.cpp:(.text+0x129=
 ): first defined here
 ld: /usr/lib/libc.a(atexit.o): in function `__cxa_atexit':
 atexit.c:(.text+0xe4): multiple definition of `__cxa_atexit'; =
 /usr/lib/liblsan.a(lsan_interceptors.o):lsan_interceptors.cpp:(.text+0x56)=
 : first defined here
 ld: /usr/lib/libc.a(atexit.o): in function `atexit':
 atexit.c:(.text+0x290): multiple definition of `atexit'; =
 /usr/lib/liblsan.a(lsan_interceptors.o):lsan_interceptors.cpp:(.text+0x94)=
 : first defined here
 ld: /usr/lib/libc.a(jemalloc.o): in function `malloc':
 jemalloc.c:(.text+0x921f): multiple definition of `malloc'; =
 /usr/lib/liblsan.a(lsan_interceptors.o):lsan_interceptors.cpp:(.text+0x1e0=
 8): first defined here
 ld: /usr/lib/libc.a(jemalloc.o): in function `posix_memalign':
 jemalloc.c:(.text+0x92f1): multiple definition of `posix_memalign'; =
 /usr/lib/liblsan.a(lsan_interceptors.o):lsan_interceptors.cpp:(.text+0x7bb=
 ): first defined here
 ld: /usr/lib/libc.a(jemalloc.o): in function `aligned_alloc':
 jemalloc.c:(.text+0x997a): multiple definition of `aligned_alloc'; =
 /usr/lib/liblsan.a(lsan_interceptors.o):lsan_interceptors.cpp:(.text+0x5bb=
 ): first defined here
 ld: /usr/lib/libc.a(jemalloc.o): in function `calloc':
 jemalloc.c:(.text+0x9fa0): multiple definition of `calloc'; =
 /usr/lib/liblsan.a(lsan_interceptors.o):lsan_interceptors.cpp:(.text+0x19b=
 3): first defined here
 ld: /usr/lib/libc.a(jemalloc.o): in function `free':
 jemalloc.c:(.text+0xabd0): multiple definition of `free'; =
 /usr/lib/liblsan.a(lsan_interceptors.o):lsan_interceptors.cpp:(.text+0x18d=
 9): first defined here
 ld: /usr/lib/libc.a(jemalloc.o): in function `valloc':
 jemalloc.c:(.text+0xac86): multiple definition of `valloc'; =
 /usr/lib/liblsan.a(lsan_interceptors.o):lsan_interceptors.cpp:(.text+0x4c3=
 ): first defined here
 ld: /usr/lib/libc.a(jemalloc.o): in function `realloc':
 jemalloc.c:(.text+0xc53f): multiple definition of `realloc'; =
 /usr/lib/liblsan.a(lsan_interceptors.o):lsan_interceptors.cpp:(.text+0x1b2=
 d): first defined here
 Exit 1

 Should we fix them (by putting the methods in separate files? I don't =
 think that it will work if we do.
 Should we provide libsanitizer.spec?

 christos





 --Apple-Mail=_6B2B9F26-2CF6-49AF-8883-96257DE7A8CE
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename=signature.asc
 Content-Type: application/pgp-signature;
 	name=signature.asc
 Content-Description: Message signed with OpenPGP

 -----BEGIN PGP SIGNATURE-----
 Comment: GPGTools - http://gpgtools.org

 iF0EARECAB0WIQS+BJlbqPkO0MDBdsRxESqxbLM7OgUCZ9wcQAAKCRBxESqxbLM7
 OsEhAKCfXto9aWuS2vqltlQ5EY3y0QAICACgom/u7u4hhhimVL5sRg/4Rl5ELCo=
 =bNdP
 -----END PGP SIGNATURE-----

 --Apple-Mail=_6B2B9F26-2CF6-49AF-8883-96257DE7A8CE--

From: RVP <rvp@SDF.ORG>
To: gnats-bugs@netbsd.org
Cc: Christos Zoulas <christos@zoulas.com>, toolchain-manager@netbsd.org
Subject: Re: toolchain/59189: leak sanitizer broken
Date: Sat, 22 Mar 2025 09:46:37 +0000 (UTC)

 On Thu, 20 Mar 2025, Christos Zoulas wrote:

 > So it dies jumping to 0 when trying to call the real ataxit() from __interceptor_atexit() in the call ataxit(cleanup) from crt0.
 > [...]
 > Something seems to be wrong with the relocation record of ataxit() but it is supposed to work
 > because the dynamic linking has finished. Adding -Wl,-z,now does not help either.
 >

 Yeah. I think what's happening on NetBSD-HEAD is:

 1. src/lib/csu/common/crt0-common.c calls atexit() before calling _preinit()--which
     would've called libsanitizer/lsan/lsan_preinit.cpp:__lsan_init() to fill in
     the address of the real atexit().

 2. Because the LSAN atexit() isn't defined as a weak symbol, _that_ gets called
     instead of the libc one--which then crashes when it calls NULL.

 (I don't know why this works on NetBSD 10.x: something must be causing __lsan_init()
 to be called there; or, it's fluke that it works...)

 Anyway, I've come up with 2 patches. The first, just calls __lsan_init() in the
 atexit() and __cxa_atexit() LSAN wrappers. (I tried using `ENSURE_LSAN_INITED'
 similar to `ENSURE_ASAN_INITED', but that doesn't work for some reason...)
 This is a bit of hack, but, seems to work.

 ```
 diff -urN a/src/external/gpl3/gcc/dist/libsanitizer/lsan/lsan_interceptors.cpp b/src/external/gpl3/gcc/dist/libsanitizer/lsan/lsan_interceptors.cpp
 --- a/src/external/gpl3/gcc/dist/libsanitizer/lsan/lsan_interceptors.cpp	2023-07-31 01:44:55.000000000 +0000
 +++ b/src/external/gpl3/gcc/dist/libsanitizer/lsan/lsan_interceptors.cpp	2025-03-22 08:04:16.230083864 +0000
 @@ -367,6 +367,8 @@
   #if SANITIZER_INTERCEPT___CXA_ATEXIT
   INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void *arg,
               void *dso_handle) {
 +  if (!lsan_inited && !lsan_init_is_running)
 +    __lsan_init();
     __lsan::ScopedInterceptorDisabler disabler;
     return REAL(__cxa_atexit)(func, arg, dso_handle);
   }
 @@ -377,6 +379,8 @@

   #if SANITIZER_INTERCEPT_ATEXIT
   INTERCEPTOR(int, atexit, void (*f)()) {
 +  if (!lsan_inited && !lsan_init_is_running)
 +    __lsan_init();
     __lsan::ScopedInterceptorDisabler disabler;
     return REAL(__cxa_atexit)((void (*)(void *a))f, 0, 0);
   }
 diff -urN a/src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_flags.inc b/src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_flags.inc
 --- a/src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_flags.inc	2023-07-31 01:44:56.000000000 +0000
 +++ b/src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_flags.inc	2025-03-22 08:13:00.083831970 +0000
 @@ -28,7 +28,7 @@
       "Path to external symbolizer. If empty, the tool will search $PATH for "
       "the symbolizer.")
   COMMON_FLAG(
 -    bool, allow_addr2line, false,
 +    bool, allow_addr2line, true,
       "If set, allows online symbolizer to run addr2line binary to symbolize "
       "stack traces (addr2line will only be used if llvm-symbolizer binary is "
       "unavailable.")
 ```

 The second one is to do things the Linux way: call the `.preinit_array'
 functions first, _then_ call atexit(); and provide a spec for GCC.
 (Note: I haven't tested this spec...):

 ```
 diff -urN a/src/lib/csu/common/crt0-common.c b/src/lib/csu/common/crt0-common.c
 --- a/src/lib/csu/common/crt0-common.c	2024-01-19 19:22:17.000000000 +0000
 +++ b/src/lib/csu/common/crt0-common.c	2025-03-22 07:51:24.617231789 +0000
 @@ -317,9 +317,6 @@
   		__progname = empty_string;
   	}

 -	if (cleanup != NULL)
 -		atexit(cleanup);
 -
   	_libc_init();

   	if (&rtld_DYNAMIC == NULL) {
 @@ -333,6 +330,9 @@

   	_preinit();

 +	if (cleanup != NULL)
 +		atexit(cleanup);
 +
   #ifdef MCRT0
   	atexit(_mcleanup);
   	monstartup((u_long)&__eprol, (u_long)&__etext);
 diff -urN a/src/external/gpl3/gcc/dist/gcc/config/netbsd.h b/src/external/gpl3/gcc/dist/gcc/config/netbsd.h
 --- a/src/external/gpl3/gcc/dist/gcc/config/netbsd.h	2023-07-31 01:46:31.000000000 +0000
 +++ b/src/external/gpl3/gcc/dist/gcc/config/netbsd.h	2025-03-22 08:18:31.573486823 +0000
 @@ -204,8 +204,29 @@
       netbsd_patch_builtins ();						\
     } while(0)

 +/* Link -lasan early on the command line.  For -static-libasan, don't link
 +   it for -shared link, the executable should be compiled with -static-libasan
 +   in that case, and for executable link with --{,no-}whole-archive around
 +   it to force everything into the executable.  And similarly for -ltsan,
 +   -lhwasan, and -llsan.  */
   #if defined(HAVE_LD_STATIC_DYNAMIC)
 +#undef LIBASAN_EARLY_SPEC
 +#define LIBASAN_EARLY_SPEC "%{!shared:libasan_preinit%O%s} " \
 +  "%{static-libasan:%{!shared:" \
 +  LD_STATIC_OPTION " --whole-archive -lasan --no-whole-archive " \
 +  LD_DYNAMIC_OPTION "}}%{!static-libasan:-lasan}"
 +#undef LIBHWASAN_EARLY_SPEC
 +#define LIBHWASAN_EARLY_SPEC "%{static-libhwasan:%{!shared:" \
 +  LD_STATIC_OPTION " --whole-archive -lhwasan --no-whole-archive " \
 +  LD_DYNAMIC_OPTION "}}%{!static-libhwasan:-lhwasan}"
   #undef LIBTSAN_EARLY_SPEC
 -#define LIBTSAN_EARLY_SPEC "%{static-libtsan:" LD_STATIC_OPTION "}"	\
 -  " -ltsan %{static-libtsan:" LD_DYNAMIC_OPTION "} -lpthread"
 +#define LIBTSAN_EARLY_SPEC "%{!shared:libtsan_preinit%O%s} " \
 +  "%{static-libtsan:%{!shared:" \
 +  LD_STATIC_OPTION " --whole-archive -ltsan --no-whole-archive " \
 +  LD_DYNAMIC_OPTION "}}%{!static-libtsan:-ltsan}"
 +#undef LIBLSAN_EARLY_SPEC
 +#define LIBLSAN_EARLY_SPEC "%{!shared:liblsan_preinit%O%s} " \
 +  "%{static-liblsan:%{!shared:" \
 +  LD_STATIC_OPTION " --whole-archive -llsan --no-whole-archive " \
 +  LD_DYNAMIC_OPTION "}}%{!static-liblsan:-llsan}"
   #endif
 ```

 The spec will rely on there now being files called libasan_preinit.o,
 liblsan_preinit.o, etc., in the compiler-specific lib. directory--like on Linux:

 ```
 $ find /usr/ -name lib*_preinit.o 2>/dev/null
 /usr/lib/gcc/x86_64-linux-gnu/13/libhwasan_preinit.o
 /usr/lib/gcc/x86_64-linux-gnu/13/libtsan_preinit.o
 /usr/lib/gcc/x86_64-linux-gnu/13/libasan_preinit.o
 /usr/lib/gcc/x86_64-linux-gnu/13/liblsan_preinit.o
 $
 ```

 (Some Makefile magic is surely needed for this... :))

 HTH,

 -RVP

 PS. My test code follows:

 ```base64 mylsan.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bzcj4hv8yW4N2vYLULSZ4ixDp81A8/L9R8nsKC8iSNwC7T
 vyF1c0J1JCHDGwahRABERBHWCkbxi6BdIcuQrJIvC5M3T+ltqGH7RjHPmA7jUjbQVEagKpGFMTal
 2HNdVXnAXxFMMTuLxNdR2mkVB72zwO1aCWZVnmxy15pZzDqVhmpFZi2oqoF1r6kXGYFFghi2LepS
 OJMg/LYFkpAgoNIyITUJai8SzAvLhpI+chJIhIeQCsoVSZLwBjRMgoHQYoEQLcAydAK5JSSsGxW1
 INZcl5EvcNJpjWPKNftGlyADvSvFCGLuF2gajGyqDzaFCRBCWALM0KLYwoNdow2gKiSR7WXBholB
 50jiAkl0BojDQaQ0DOyBiX/xdyRThQkL6l1b4A==
 ```

From: Christos Zoulas <christos@zoulas.com>
To: RVP <rvp@sdf.org>
Cc: gnats-bugs@netbsd.org,
 toolchain-manager@netbsd.org
Subject: Re: toolchain/59189: leak sanitizer broken
Date: Sat, 22 Mar 2025 12:20:34 -0400

 --Apple-Mail=_01562FF4-1AC2-412C-8422-64E1435F114D
 Content-Transfer-Encoding: quoted-printable
 Content-Type: text/plain;
 	charset=us-ascii

 Thanks for working on this. No more coredumps, but it does not detect =
 leaks either. Static linking still does not work.

 I tried the spec and it works. To install preinit files:

 $ cat /usr/src/external/gpl3/gcc/lib/preinit.mk
 # $NetBSD$

 FILE=3Dlib${LIB}_preinit.o
 FILES+=3D${FILE}
 FILESDIR=3D/usr/lib
 CLEANFILES+=3D${FILE} ${LIB}_preinit.o

 ${FILE}: ${LIB}_preinit.o
 	${_MKTARGET_CREATE}
         cp ${.ALLSRC} ${.TARGET}

 .include <bsd.files.mk>
 $ cvs diff Makefile
 [12:16pm] 18>cvs diff Makefile=20
 Index: Makefile
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 RCS file: /cvsroot/src/external/gpl3/gcc/lib/liblsan/Makefile,v
 retrieving revision 1.10
 diff -u -p -r1.10 Makefile
 --- Makefile    30 Sep 2024 00:32:12 -0000      1.10
 +++ Makefile    22 Mar 2025 16:16:44 -0000
 @@ -28,4 +28,6 @@ LIBDPLIBS+=3D pthread ${NETBSDSRCDIR}/lib/
 =20
  CWARNFLAGS.clang+=3D     -Wno-error=3Dunused-private-field
 =20
 +.include "../preinit.mk"
 +
  .include <bsd.lib.mk>


 christos


 --Apple-Mail=_01562FF4-1AC2-412C-8422-64E1435F114D
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename=signature.asc
 Content-Type: application/pgp-signature;
 	name=signature.asc
 Content-Description: Message signed with OpenPGP

 -----BEGIN PGP SIGNATURE-----
 Comment: GPGTools - http://gpgtools.org

 iF0EARECAB0WIQS+BJlbqPkO0MDBdsRxESqxbLM7OgUCZ97jUgAKCRBxESqxbLM7
 OoMPAJ0S7dSJAxIiVdif6aKK1dkhbuYyzgCg4FY5B8kBrq+LVZ5ZQs54oiU0ckY=
 =A6gd
 -----END PGP SIGNATURE-----

 --Apple-Mail=_01562FF4-1AC2-412C-8422-64E1435F114D--

From: Christos Zoulas <christos@zoulas.com>
To: RVP <rvp@sdf.org>
Cc: gnats-bugs@netbsd.org,
 toolchain-manager@netbsd.org
Subject: Re: toolchain/59189: leak sanitizer broken
Date: Sat, 22 Mar 2025 12:31:43 -0400

 --Apple-Mail=_43AFE604-3279-4242-925A-D1A533D37934
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain;
 	charset=us-ascii

 Sorry, it does detect leaks. The optimizer took out the malloc code.

 christos

 --Apple-Mail=_43AFE604-3279-4242-925A-D1A533D37934
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename=signature.asc
 Content-Type: application/pgp-signature;
 	name=signature.asc
 Content-Description: Message signed with OpenPGP

 -----BEGIN PGP SIGNATURE-----
 Comment: GPGTools - http://gpgtools.org

 iF0EARECAB0WIQS+BJlbqPkO0MDBdsRxESqxbLM7OgUCZ97l7wAKCRBxESqxbLM7
 OkIXAJ4iCeVXetQlrC6+hd50xnb0lbSqwgCgyr8tP06pu4afqnj+zJf4f8kyvCM=
 =Hyb0
 -----END PGP SIGNATURE-----

 --Apple-Mail=_43AFE604-3279-4242-925A-D1A533D37934--

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59189 CVS commit: src/lib/csu/common
Date: Sat, 22 Mar 2025 12:59:02 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Sat Mar 22 16:59:02 UTC 2025

 Modified Files:
 	src/lib/csu/common: crt0-common.c

 Log Message:
 PR/59189: RVP: move atexit(cleanup) after _preinit() to allow sanitizer
 initialization during preinit as well as atexit interception.


 To generate a diff of this commit:
 cvs rdiff -u -r1.28 -r1.29 src/lib/csu/common/crt0-common.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59189 CVS commit: src/external/gpl3/gcc
Date: Sat, 22 Mar 2025 13:05:48 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Sat Mar 22 17:05:48 UTC 2025

 Modified Files:
 	src/external/gpl3/gcc/dist/gcc/config: netbsd.h
 	src/external/gpl3/gcc/lib/libasan: Makefile
 	src/external/gpl3/gcc/lib/liblsan: Makefile
 	src/external/gpl3/gcc/lib/libtsan: Makefile
 Added Files:
 	src/external/gpl3/gcc/lib: preinit.mk

 Log Message:
 PR/59189: RVP: Like Linux and FreeBSD use .preinit_array to initialize the
 sanitizers.


 To generate a diff of this commit:
 cvs rdiff -u -r1.40 -r1.41 src/external/gpl3/gcc/dist/gcc/config/netbsd.h
 cvs rdiff -u -r0 -r1.1 src/external/gpl3/gcc/lib/preinit.mk
 cvs rdiff -u -r1.37 -r1.38 src/external/gpl3/gcc/lib/libasan/Makefile
 cvs rdiff -u -r1.10 -r1.11 src/external/gpl3/gcc/lib/liblsan/Makefile
 cvs rdiff -u -r1.17 -r1.18 src/external/gpl3/gcc/lib/libtsan/Makefile

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Thomas Klausner <wiz@NetBSD.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: toolchain/59189: leak sanitizer broken
Date: Mon, 24 Mar 2025 08:22:44 +0100

 The committed fixes make both test programs work for me, thank you!

 Can someone(TM) please also add a test?
  Thomas

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2025 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.