Skip Menu |

This queue is for tickets about the Devel-MAT CPAN distribution.

Report information
The Basics
Id: 103499
Status: resolved
Priority: 0/
Queue: Devel-MAT

People
Owner: Nobody in particular
Requestors: TEAM [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.20
Fixed in: 0.21



Subject: Duplicate copy of main stash
Not sure if this is intentional, but it appears that there are two copies of the 'main' stash in the generated PMAT files? Attached an example (trivial) pmat file from 0.20. Stash [main] at offset 165365 is at 0x1119fc8 Stash [main] at offset 185180 is at 0x1119fc8 Seems like the second copy is identical, at least from a quick glance at hexdump output. cheers, Tom
Subject: sample.pmat
Download sample.pmat
application/octet-stream 180.9k

Message body not shown because it is not plain text.

On Mon Apr 13 15:02:49 2015, TEAM wrote: Show quoted text
> Not sure if this is intentional, but it appears that there are two > copies of the 'main' stash in the generated PMAT files? > > Attached an example (trivial) pmat file from 0.20. > > Stash [main] at offset 165365 is at 0x1119fc8 > Stash [main] at offset 185180 is at 0x1119fc8 > > Seems like the second copy is identical, at least from a quick glance > at hexdump output.
[recorded for interest even though we discussed it IRL] At least some versions of perl don't allocate the main stash on the arena, so it has to be dumped specially. It would appear that in fact some perls *do* keep it on the arena, and those perls will output it twice. This was fixed by theattached patch. -- Paul Evans
Subject: rt103499.patch
=== modified file 'lib/Devel/MAT/Dumper.xs' --- lib/Devel/MAT/Dumper.xs 2014-01-22 21:25:15 +0000 +++ lib/Devel/MAT/Dumper.xs 2015-04-16 18:39:49 +0000 @@ -830,6 +830,8 @@ for(sp = PL_stack_base; sp <= PL_stack_sp; sp++) write_svptr(fh, *sp); + bool seen_defstash = false; + // Heap SV *arena; for(arena = PL_sv_arenaroot; arena; arena = (SV *)SvANY(arena)) { @@ -844,11 +846,15 @@ } write_sv(fh, sv); + + if(sv == (const SV *)PL_defstash) + seen_defstash = true; } } // and a few other things that don't actually appear in the arena - write_sv(fh, (const SV *)PL_defstash); + if(!seen_defstash) + write_sv(fh, (const SV *)PL_defstash); write_u8(fh, 0);
Released -- Paul Evans