develooper Front page | perl.perl5.porters | Postings from April 2017

[perl #129990] Reduce malloc&free for S_parse_gv_stash_name

Thread Previous
From:
Atoomic via RT
Date:
April 27, 2017 17:09
Subject:
[perl #129990] Reduce malloc&free for S_parse_gv_stash_name
Message ID:
rt-4.0.24-30720-1493312976-508.129990-15-0@perl.org
Indeed removing the last free lead to a leak. 

We should then consider the previous patch which is a global improvement IMO,
we can also consider dropping support for quote as a package separator.

I'm also considering using a small buffer to avoid the malloc in most cases (similar trick than the one used by S_gv_stashpvn_internal ), will probably open another ticket for it, but here is the patch: https://github.com/atoomic/perl5/commit/adda0b6b3fadb22090d53d54c4f9d5c77fdf0372

Merging the two ideas might lead to the expected combo.

Any thoughts ?

On Mon, 14 Nov 2016 21:47:03 -0800, tonyc wrote:
> On Sun, 13 Nov 2016 02:41:40 -0800, atoomic wrote:
> > Here is an improved patch that solves the single package issue
> > Using the same benchmark tests, here are the updated results
> 
> The improved patch leaks the memory allocated in
> S_parse_gv_stash_name:
> 
> tony@mars:.../git/perl$ cat ../129990.pl
> sub xx'yy'foo {}
> 
> $x = "xx'yy'foo";
> 
> &$x;
> 
> tony@mars:.../git/perl$ PERL_DESTRUCT_LEVEL=2 valgrind --leak-
> check=full ./perl ../129990.pl
> ==18383== Memcheck, a memory error detector
> ==18383== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et
> al.
> ==18383== Using Valgrind-3.10.0 and LibVEX; rerun with -h for
> copyright info
> ==18383== Command: ./perl ../129990.pl
>  ==18383==
>  ==18383==
> ==18383== HEAP SUMMARY:
> ==18383==     in use at exit: 11 bytes in 1 blocks
> ==18383==   total heap usage: 783 allocs, 782 frees, 141,865 bytes
> allocated
>  ==18383==
> ==18383== 11 bytes in 1 blocks are definitely lost in loss record 1 of
> 1
> ==18383==    at 0x4C28C20: malloc (in
> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==18383==    by 0x55853B: Perl_safesysmalloc (util.c:153)
> ==18383==    by 0x479100: S_parse_gv_stash_name (gv.c:1620)
> ==18383==    by 0x47ED8F: Perl_gv_fetchpvn_flags (gv.c:2325)
> ==18383==    by 0x461568: Perl_get_cvn_flags (perl.c:2636)
> ==18383==    by 0x5B7DB6: Perl_pp_entersub (pp_hot.c:3978)
> ==18383==    by 0x556D2C: Perl_runops_debug (dump.c:2235)
> ==18383==    by 0x460E71: S_run_body (perl.c:2526)
> ==18383==    by 0x460454: perl_run (perl.c:2449)
> ==18383==    by 0x41EF9D: main (perlmain.c:123)
>  ==18383==
> ==18383== LEAK SUMMARY:
> ==18383==    definitely lost: 11 bytes in 1 blocks
> ==18383==    indirectly lost: 0 bytes in 0 blocks
> ==18383==      possibly lost: 0 bytes in 0 blocks
> ==18383==    still reachable: 0 bytes in 0 blocks
> ==18383==         suppressed: 0 bytes in 0 blocks
>  ==18383==
> ==18383== For counts of detected and suppressed errors, rerun with: -v
> ==18383== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from
> 0)
> 
> Tony




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

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