develooper Front page | perl.perl5.porters | Postings from June 2022

Re: PERL_MEM_LOG - broken and useless

Thread Previous | Thread Next
From:
Paul "LeoNerd" Evans
Date:
June 9, 2022 17:54
Subject:
Re: PERL_MEM_LOG - broken and useless
Message ID:
20220609185348.4951ce38@shy.leonerd.org.uk
On Thu, 9 Jun 2022 18:39:46 +0100 (BST)
"G.W. Haywood" via perl5-porters <perl5-porters@perl.org> wrote:

> Hi there,
> 
> On Thu, 9 Jun 2022, Paul "LeoNerd" Evans wrote:
> 
> > I've been trying to track down a tricky memory-leak bug...  
> 
> I have an interest[1] but I haven't seen much evidence of leaks.
> 
> What does one need to do to trigger this leak?

Heh - that's rather specific to my code.

In this case: I'm writing an XS version of Future; which is failing one
refcount test:

  $ bleadperl -Mblib t/06followed_by.t 
  ok 1 - $fseq defined
  ...
  not ok 11 - $f1 has refcount 1 before EOF
  #   Failed test '$f1 has refcount 1 before EOF'
  #   at ../Future/t/lib/FutureTests.pm line 772.
  #   expected 1 references, found 2
  # SV address is 0x55bf93a73510
  # Writing heap dump to t/06followed_by-11.pmat

This SV has two references but we were only expecting one.

So I go investigating that:

  $ pmat t/06followed_by-11.pmat 
  Perl memory dumpfile from perl 5.37.1 threaded
  Heap contains 32563 objects
  pmat> show 0x55bf93a73510
  SCALAR(UV)=Future::XS at 0x55bf93a73510 with refcount 2
    size 72 bytes
    blessed as Future::XS
    has < magic with object at REF(W) at 0x55bf943d6408
       with virtual table at 0x55bf938a4580
    UV=94281304555144

  pmat> identify 0x55bf93a73510
  SCALAR(UV)=Future::XS at 0x55bf93a73510 is:
  ├─the referrant of REF() at 0x55bf93ad0080, which is:
  │ └─not found
  └─the referrant of REF() at 0x55bf944b81d8, which is:
    ├─the lexical $f1 at depth 1 of CODE(PP,closure) at 0x55bf93aa2558,
    which is:
  ... (lots more lines which are expected)

Of these two REFs, the second one was the expected one, but that first
one ought to have been deleted by now. It's still hanging around. But I
can't identify it further, because DMD couldn't find any pointer that
pointed at it. It's been leaked somewhere :(

This is where I now need the memory log, so I can go back and read what
the full C backtrace was at the time that SV (at address
0x55bf93ad0080) was created.

This is the task for which I need `PERL_MEM_LOG=sc` with my
newly-created 'c' flag.

-- 
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/

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