From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by sourceware.org (Postfix) with ESMTPS id 5C4E5385BF83 for ; Tue, 16 Nov 2021 21:38:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5C4E5385BF83 Received: by mail-ed1-x536.google.com with SMTP id m20so1156996edc.5 for ; Tue, 16 Nov 2021 13:38:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+WmF3/FrsLugGtx97/POI+6XcOzDkqZVWQKTBfAbSMY=; b=1R1tk11jTx2a8PoMy5SLmdiZyxTXPhL8CfC3ZdwTkbeYIfk5P8LKuxEiPHCv1fVZCr WOY5rPl1OiBC6taDK18ZYcC3gaJ87QgclaJm4OAV6ZeMflAPfEgHc04BUl06OghB2xqE 1I4RIagKIajj/mJkRNbZBfj4skebSP+qUd8KJujHkBHDjQBqc97t6J/6OUShmBpMaTfl K6XYwQgnxbTQ7NJrbj070JxkKnLgu9D86ovpOcKalmWoStiXT8IIcNzrvhkTP6xqHefh NtKfPk6Hqs7g+XS1Nad3oOqQvBZa1hCh5qWTzT8YdSYyA6sH/vc0ES7lfGmNrAbaGd5/ CoZg== X-Gm-Message-State: AOAM531VpodIklMHgy7WvU9tz5FKnMiKwdV7SYKZKBcz2X7YJAGAURvX J5e8wUPiPeVoSvmUIlnKgQP4BrSCAj5NUnzY/FTZTTq/x/c= X-Google-Smtp-Source: ABdhPJw0SGL9EEAPAeJJStfsofclMZHDXfludAwBNguoVXzsuVr/v/bNNR722RCiRHSwt3lodqSIr3Gh7tWeYNd2Ddk= X-Received: by 2002:a17:907:9606:: with SMTP id gb6mr13786789ejc.287.1637098703917; Tue, 16 Nov 2021 13:38:23 -0800 (PST) MIME-Version: 1.0 References: <20211116213225.3032782-1-shorne@gmail.com> In-Reply-To: <20211116213225.3032782-1-shorne@gmail.com> From: Stafford Horne Date: Wed, 17 Nov 2021 06:38:12 +0900 Message-ID: Subject: Re: [PATCH v2] malloc: Fix malloc debug for 2.35 onwards To: GLIBC patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Nov 2021 21:38:27 -0000 On Wed, Nov 17, 2021 at 6:32 AM Stafford Horne wrote: > > The change 1e5a5866cb ("Remove malloc hooks [BZ #23328]") has broken > ports that are using GLIBC_2_35, like the new OpenRISC port I am working > on. > > The libc_malloc_debug.so library used to bring in the debug > infrastructure is currently essentially empty for GLIBC_2_35 ports like > mine causing mtrace tests to fail: > > cat sysdeps/unix/sysv/linux/or1k/shlib-versions > DEFAULT GLIBC_2.35 > ld=ld-linux-or1k.so.1 > > FAIL: posix/bug-glob2-mem > FAIL: posix/bug-regex14-mem > FAIL: posix/bug-regex2-mem > FAIL: posix/bug-regex21-mem > FAIL: posix/bug-regex31-mem > FAIL: posix/bug-regex36-mem > FAIL: malloc/tst-mtrace. > > The issue seems to be with the ifdefs in malloc/malloc-debug.c. The > ifdefs are currently essentially exluding all symbols for ports > 2.35. > > Removing the top level SHLIB_COMPAT ifdef allows things to just work. > > Fixes: 1e5a5866cb ("Remove malloc hooks [BZ #23328]") > Cc: Siddhesh Poyarekar > --- > > Changes since v2: > - Just remove SHLIB_COMPAT, using compat_symbol seems to do what > Siddhesh was explaining he wanted to do. > > malloc/malloc-debug.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/malloc/malloc-debug.c b/malloc/malloc-debug.c > index 3d7e6d44fd..99aa95b145 100644 > --- a/malloc/malloc-debug.c > +++ b/malloc/malloc-debug.c > @@ -24,7 +24,6 @@ > #include > #include > > -#if SHLIB_COMPAT (libc_malloc_debug, GLIBC_2_0, GLIBC_2_34) > /* Support only the glibc allocators. */ > extern void *__libc_malloc (size_t); > extern void __libc_free (void *); > @@ -669,4 +668,3 @@ compat_symbol (libc_malloc_debug, __free_hook, __free_hook, GLIBC_2_0); > compat_symbol (libc_malloc_debug, __malloc_hook, __malloc_hook, GLIBC_2_0); > compat_symbol (libc_malloc_debug, __realloc_hook, __realloc_hook, GLIBC_2_0); > compat_symbol (libc_malloc_debug, __memalign_hook, __memalign_hook, GLIBC_2_0); > -#endif > -- > 2.31.1 > Note, after this patch objdump -T looks like following below. Note, this just works because when we use GLIBC_2_0 in compat_symbol it automatically forwards to the ports default/first version. Also, tests pass for me. ../build-glibc/malloc/libc_malloc_debug.so: file format elf32-big DYNAMIC SYMBOL TABLE: 00001114 l d .text 00000000 .text 0000a7d0 l d .rodata 00000000 .rodata 0000b7c8 l d .eh_frame 00000000 .eh_frame 0000df00 l d .tbss 00000000 .tbss 0000e000 l d .data 00000000 .data 0000e574 l d .bss 00000000 .bss 00000000 DF *UND* 00000000 GLIBC_2.35 fclose 00000000 DF *UND* 00000000 GLIBC_2.35 __libc_free 00000000 DF *UND* 00000000 GLIBC_PRIVATE __lll_lock_wake_private 00000000 w D *UND* 00000000 Base _ITM_deregisterTMCloneTable 00000000 D *UND* 00000000 GLIBC_PRIVATE errno 00000000 DF *UND* 00000000 GLIBC_2.35 __libc_memalign 00000000 DF *UND* 00000000 GLIBC_PRIVATE __libc_fatal 00000000 DO *UND* 00000000 GLIBC_2.35 _libc_intl_domainname 00000000 DF *UND* 00000000 GLIBC_PRIVATE __mmap 00000000 DF *UND* 00000000 GLIBC_2.35 __libc_malloc 00000000 DF *UND* 00000000 GLIBC_PRIVATE __munmap 00000000 DF *UND* 00000000 GLIBC_2.35 __assert_fail 00000000 DO *UND* 00000000 GLIBC_PRIVATE __libc_enable_secure 00000000 DF *UND* 00000000 GLIBC_2.35 dlsym 00000000 DF *UND* 00000000 GLIBC_2.35 mremap 00000000 DF *UND* 00000000 GLIBC_PRIVATE __open_nocancel 00000000 DF *UND* 00000000 GLIBC_2.35 setvbuf 00000000 DF *UND* 00000000 GLIBC_2.35 sprintf 00000000 DF *UND* 00000000 GLIBC_2.35 __sbrk 00000000 w DF *UND* 00000000 GLIBC_2.35 __cxa_finalize 00000000 DF *UND* 00000000 GLIBC_2.35 __dcgettext 00000000 DF *UND* 00000000 GLIBC_PRIVATE __mprotect 00000000 DO *UND* 00000000 GLIBC_PRIVATE _rtld_global_ro 00000000 DF *UND* 00000000 GLIBC_2.35 fopen 00000000 DF *UND* 00000000 GLIBC_2.35 funlockfile 00000000 DF *UND* 00000000 GLIBC_2.35 sysconf 00000000 DF *UND* 00000000 GLIBC_2.35 flockfile 00000000 DF *UND* 00000000 GLIBC_PRIVATE __read_nocancel 00000000 DO *UND* 00000000 GLIBC_2.35 stderr 00000000 DF *UND* 00000000 GLIBC_2.35 memset 00000000 DF *UND* 00000000 GLIBC_2.35 __libc_realloc 00000000 DF *UND* 00000000 GLIBC_2.35 fprintf 00000000 DF *UND* 00000000 GLIBC_2.35 secure_getenv 00000000 DF *UND* 00000000 GLIBC_2.35 __libc_freeres 00000000 DF *UND* 00000000 GLIBC_PRIVATE __madvise 00000000 DF *UND* 00000000 GLIBC_2.35 strlen 00000000 DF *UND* 00000000 GLIBC_2.35 memcpy 00000000 DF *UND* 00000000 GLIBC_2.35 dladdr 00000000 DF *UND* 00000000 GLIBC_PRIVATE __tunable_get_val 00000000 DF *UND* 00000000 GLIBC_2.35 __cxa_atexit 00000000 w D *UND* 00000000 Base _ITM_registerTMCloneTable 00000000 DF *UND* 00000000 GLIBC_PRIVATE __lll_lock_wait_private 00000000 DF *UND* 00000000 GLIBC_PRIVATE __close_nocancel 00000000 DF *UND* 00000000 GLIBC_2.35 fwrite 0000e498 g DO .data 00000004 (GLIBC_2.35) __realloc_hook 0000e7c8 g DO .bss 00000004 (GLIBC_2.35) __free_hook 00000000 g DO *ABS* 00000000 GLIBC_2.35 GLIBC_2.35 00009804 g DF .text 00000024 (GLIBC_2.35) mcheck_pedantic 00009c1c g DF .text 00000104 (GLIBC_2.35) pvalloc 000095ec g DF .text 0000011c (GLIBC_2.35) free 0000a478 g DF .text 00000138 (GLIBC_2.35) mallinfo2 000099b8 g DF .text 000001a4 (GLIBC_2.35) realloc 00009d20 g DF .text 000000a8 (GLIBC_2.35) valloc 00004440 g DF .text 00000024 (GLIBC_2.35) mcheck_check_all 00004464 g DF .text 00000020 (GLIBC_2.35) mprobe 0000e494 g DO .data 00000004 (GLIBC_2.35) __memalign_hook 00009ba4 g DF .text 00000030 (GLIBC_2.35) aligned_alloc 0000e49c g DO .data 00000004 (GLIBC_2.35) __malloc_hook 0000a1bc g DF .text 000000f8 (GLIBC_2.35) malloc_info 000044a4 g DF .text 00000020 (GLIBC_2.35) muntrace 0000a128 g DF .text 00000094 (GLIBC_2.35) malloc_usable_size 00009dc8 g DF .text 000000bc (GLIBC_2.35) posix_memalign 000097e0 g DF .text 00000024 (GLIBC_2.35) mcheck 00004484 g DF .text 00000020 (GLIBC_2.35) mtrace 0000a3ac g DF .text 000000cc (GLIBC_2.35) malloc_stats 00009e84 g DF .text 000002a4 (GLIBC_2.35) calloc 0000a6e8 g DF .text 000000e8 (GLIBC_2.35) malloc_trim 00009ba4 g DF .text 00000030 (GLIBC_2.35) memalign 00009190 g DF .text 00000180 (GLIBC_2.35) malloc 0000a5b0 g DF .text 00000138 (GLIBC_2.35) mallinfo 0000a2b4 g DF .text 000000f8 (GLIBC_2.35) mallopt