[DragonFlyBSD - Bug #3361] newlocale()/freelocale() leak
mneumann
bugtracker-admin at leaf.dragonflybsd.org
Mon Jun 29 00:07:04 PDT 2026
Issue #3361 has been updated by mneumann.
The patch looks good. Do you have the FreeBSD commit at hand so we can reference it in the commit?
Basically, without your patch, `destruct_collate` skips the `munmap` call below:
static void
destruct_collate(void *t)
{
struct xlocale_collate *table = t;
if (table->map && (table->maplen > 0)) {
(void) munmap(table->map, table->maplen);
}
free(t);
}
----------------------------------------
Bug #3361: newlocale()/freelocale() leak
http://bugs.dragonflybsd.org/issues/3361#change-14674
* Author: tonyc
* Status: New
* Priority: Normal
* Category: Userland
* Target version: 6.4
* Start date: 2023-11-16
----------------------------------------
The attached code shows the combination of newlocale() to create a new locale object and freelocale() to free that object leaks memory.
@$ ./newlocale_loop
UID PID PPID CPU PRI NI VSZ RSS WCHAN STAT TT TIME COMMAND
1001 825 822 4 178 0 4124 680 wait S0+ 0 0:00.00 ./n
UID PID PPID CPU PRI NI VSZ RSS WCHAN STAT TT TIME COMMAND
1001 825 822 80 254 0 7.63G 416616 wait S1+ 0 0:05.37 ./n
UID PID PPID CPU PRI NI VSZ RSS WCHAN STAT TT TIME COMMAND
1001 825 822 80 254 0 15.26G 832272 wait S1+ 0 0:09.62 ./n
UID PID PPID CPU PRI NI VSZ RSS WCHAN STAT TT TIME COMMAND
1001 825 822 80 254 0 22.89G 1.19G wait S1+ 0 0:12.80 ./n
UID PID PPID CPU PRI NI VSZ RSS WCHAN STAT TT TIME COMMAND
1001 825 822 80 254 0 30.52G 1.58G wait S1+ 0 0:17.34 ./n
UID PID PPID CPU PRI NI VSZ RSS WCHAN STAT TT TIME COMMAND
1001 825 822 80 254 0 38.15G 1.98G wait S1+ 0 0:18.68 ./n
UID PID PPID CPU PRI NI VSZ RSS WCHAN STAT TT TIME COMMAND
1001 825 822 80 254 0 45.78G 2.37G wait S1+ 0 0:23.65 ./n
UID PID PPID CPU PRI NI VSZ RSS WCHAN STAT TT TIME COMMAND
1001 825 822 80 254 0 53.41G 2.77G wait S1+ 0 0:26.65 ./n
UID PID PPID CPU PRI NI VSZ RSS WCHAN STAT TT TIME COMMAND
1001 825 822 80 254 0 61.04G 3.17G wait S1+ 0 0:30.35 ./n
UID PID PPID CPU PRI NI VSZ RSS WCHAN STAT TT TIME COMMAND
1001 825 822 80 254 0 68.67G 3.56G wait S1+ 0 0:35.02 ./n
@
Note RSS going from 680 to 3.56G
Building and running the same code on Linux (Debian bookworm) and Freebsd 15-CURRENT does not leak in the same way.
---Files--------------------------------
newlocale_loop.c (431 Bytes)
lib.libc.locale.collate.c.diff (508 Bytes)
--
You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://bugs.dragonflybsd.org/my/account
More information about the Bugs
mailing list