Add Packfile Segment in PIR

Mark Glines mark at glines.org
Fri Feb 20 21:30:26 UTC 2009


chromatic wrote:
> Here's a patch which nearly gets t/pmc/packfiledirectory.t working fully.  
> I've added set_pmc_keyed() and set_pmc_keyed_str() to the PackfileDirectory 
> PMC.  Unfortunately, this causes crashes when destroying the directory, as it 
> looks like I'm sharing memory in two places.
> 
> This test is a little dodgy as well, because it tries to add a segment which 
> already exists in the directory again with a different name.  I'm not sure 
> that should work, but I couldn't get other approaches to work much better.

Huh?  I don't see it copying an already-existing segment.  It looks to
me like the test creates an entirely new (empty) segment.  But I like
this latter approach better.

The problem was, the new segment structure's "type" and "pf" members
were uninitialized.  The "pf" member was NULL causing the first
segfault.  Once that worked, the "type" member was 0 (which means,
PF_DIR_SEG), making the destructor call the wrong free function, which
resulted in a second segfault.

The attached patch, applied on top of yours, gets the test passing.

Mark
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: more-fixups.patch
URL: <http://lists.parrot.org/pipermail/parrot-dev/attachments/20090220/c50226a0/attachment.diff>


More information about the parrot-dev mailing list