develooper Front page | perl.perl5.porters | Postings from February 2018

Re: [perl #132892] Possibly memory leak when matching strings usingpre-compiled regexes stored in hash key (perl >= v5.26)

Thread Previous | Thread Next
From:
demerphq
Date:
February 25, 2018 09:58
Subject:
Re: [perl #132892] Possibly memory leak when matching strings usingpre-compiled regexes stored in hash key (perl >= v5.26)
Message ID:
CANgJU+WpvWjsLVtMS8Ld6OnhVH_W=2ZJoGHn9N2KEywEOwv-aw@mail.gmail.com
On 25 February 2018 at 10:50, demerphq <demerphq@gmail.com> wrote:
> On 23 February 2018 at 14:03, Dave Mitchell <davem@iabyn.com> wrote:
>> On Fri, Feb 23, 2018 at 10:34:50AM +0100, demerphq wrote:
>>> Fixed in 910a6a8be166fb3780dcd2520e3526e537383ef2
>>>
>>> Unfortunately I don't know how to test for a memory leak, so no tests included.
>>
>> see t/op/svleak.t. It runs a bit of code several times in a loop and
>> tests whether PL_sv_count fails to remain constant.
>
> Thanks, i just pushed 06f26dc89ebc43d50835aaecc477ec160a5a5835 which
> does just that.
>
> FWIW, there is still an open question why this happens at all. Keys
> should be null terminated, and we should not fall into this code-path.

Apparently I am wrong:

$ ./perl -Ilib -MDevel::Peek -le'%h=("^foo"=>1); my ($re)=keys %h; Dump $re'
SV = PV(0x1009d08) at 0x103f0b8
  REFCNT = 1
  FLAGS = (POK,IsCOW,pPOK)
  PV = 0x1041478 "^foo"
  CUR = 4
  LEN = 0

This appears to be a side-effect of shared keys.

Another good reason not to put patterns in keys. :-(

Yves



-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Previous | 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