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

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

Thread Next
From:
Alexander Shikov
Date:
July 31, 2019 04:22
Subject:
Re: [perl #134305] Memory Leak in perl 5.28 and 5.30
Message ID:
20190730070219.GA62540@crete.itcons.net.ua
Hello!

On Mon, Jul 29, 2019 at 22:35:27 -0700, Tony Cook via RT wrote:
> 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.

Thank you for pointing this out.
Does this mean that Perl versions 5.26 and 5.28 handle locales in different way?

And what's strange is that your C code results to same memory leak on both 11.2-RELEASE
and 12.0-RELEASE, but I'm not able to reproduce an issue with Perl 5.28 on 11.2-RELEASE.

I've filled the bug in FreeBSD Bugzilla. Let's see the findings there as well.
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=239520

-- 
Alexander Shikov
Technical Staff, Digital Telecom IX
Tel.: +380 44 201 14 07
Mob.: +380 50 410 30 57
http://dtel-ix.net/

Thread Next


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