[PATCH v1 1/4] aarch64 gas: free hash tables in md_begin() to avoid memory leaks

Alice Carlotti alice.carlotti@arm.com
Mon Mar 2 18:40:01 GMT 2026


On Tue, Feb 24, 2026 at 05:39:19PM +0100, Jan Beulich wrote:
> On 24.02.2026 17:26, Matthieu Longo wrote:
> > The AArch64 GAS backend allocates several hash tables in md_begin(). All of
> > these hash tables use strings as keys; some of those strings are dynamically
> > allocated, while others are statically allocated. None of these hash tables
> > have ever been deallocated in aarch64_md_end(), resulting in memory leaks
> > that spam LeakSanitizer reports.
> > 
> > The first part of the fix deallocates the hash tables in aarch64_md_end().
> 
> By how much does this increase assembly time for small or medium size input?
> 
> Jan

I measure this series as about 5-6% slower on a test with a single nop
instruction (from a baseline of about 5ms, compiled with -O2).

I've also written an alternative patch series myself, which came out as 10%
when originally tested, or 3-4% overhead when I replaced a linked list with a
static array (with a 'magic number' size).  Of this, about 1% was from freeing
the register alias entries (although I only had 4 dynamically allocated aliases
out of 752 hash table entries), and most of the rest was from a combination of
mnemonic linked lists (approx 3600 entries) and upper case sysins strings (I
think a few hundred entries).  Freeing the hash tables had no noticeable
performance overhead.

Is a clean leak_check_at_exit report worth a 3-4% (or worse) slowdown for
startup/exit?  I think this would correspond to about a 0.5% slowdown for
running the gas testsuite on AArch64 (though I haven't measured that yet).

Alice


More information about the Binutils mailing list