develooper Front page | perl.perl5.porters | Postings from July 2019

[perl #134305] Memory Leak in perl 5.28 and 5.30

Thread Previous
From:
Tony Cook via RT
Date:
July 30, 2019 05:35
Subject:
[perl #134305] Memory Leak in perl 5.28 and 5.30
Message ID:
rt-4.0.24-17512-1564464927-77.134305-15-0@perl.org
On Tue, 23 Jul 2019 10:22:46 -0700, a.shikov@dtel-ix.net wrote:
> use strict;
> use Sys::Syslog qw(:standard :macros);
> 
> openlog('syslog-demo', 'ndelay', LOG_LOCAL2);
> 
> my $c = 0;
> 
> my @chars = ("A".."Z", "a".."z", "0".."9", "." , "-", "_" );
> 
> while ($c++ <= 10000) {
>         my $string = '';
>         $string .= $chars[rand @chars] for 1..32;
>         for (1..512) {
>                 syslog(LOG_DEBUG, "DEBUG LOG %d/%d RANDOM STRING: %s",
> $c, $_, $string );
>         }
>         sleep 1;
> }

This simplifies down to:

use POSIX qw(setlocale LC_TIME);

while (1) {
  setlocale(LC_TIME, "en_AU.UTF-8");
}

Unfortunately valgrind[1] says there's no leaks:

==28285== HEAP SUMMARY:
==28285==     in use at exit: 0 bytes in 0 blocks
==28285==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==28285== 
==28285== All heap blocks were freed -- no leaks are possible
==28285== 

I see a similar issue with the following C code:

#include <locale.h>

int main() {
  while (1) {
    locale_t n = newlocale(LC_TIME_MASK, "en_AU.UTF-8", (locale_t)0);
    locale_t old = uselocale(n);
    uselocale(old);
    freelocale(n);
  }
}

which I believe is handling the locale objects correctly, so I suspect this is a FreeBSD libc issue.

Tony

[1] from pkg install valgrind

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=134305

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About