Success! ...ish, Again!

Whiteknight on 2008-07-13T19:52:43

I ended last week with a major overhaul, reordering and refactoring of my sweep code. I was marking cards in the opposite order from how I was sweeping them, which caused me to prematurely free a number of PMCs. So I fixed that, ran it again, and...segfault. I don't get down about seeing that error anymore, it's just another hurdle to cross and I'm definitely up for the challenge.

I trace it out, and one of my PMCs is still being freed prematurely, somewhere buried deep in the hash code (i think). I know the PMC is being freed prematurely, because the PMC destruction code, Parrot_dod_free_pmc, assigns the vtable, pmc_ext, and data pointers to the oft-amusing value 0xdeadbeef. I love finding words that you can spell in hexadecimal, it brings back memories of writing out 55378008 in our calculators and turning them upside-down in math class (never done it? try it for a quick low-brow laugh).

I know the PMC in question is being freed prematurely, and there are only two places where a PMC is freed: In gc_it_add_free_object and gc_it_sweep_pmc_pools. On a hunch, I comment out the call to the later and...it compiles without error. That function in turn sweeps the pmc and const_pmc pools, so now I test commenting out each of those and figuring out which one causes the error. From there, I can try to figure out how the offending PMC gets freed in the first place: is it not being marked properly? If marked, is the sweep code not reading the mark properly? And, if both of those aren't an issue, is the PMC being improperly freed in some other way? This might be my last big core error. It might not be, of course, but I have my fingers crossed. I fix this, and hopefully I can start re-integrating some of the components I've commented out (specifically the compacting code on the Memory_Pool allocator, and the system stack tracing code). Then, when everything gets back up to a point where everything is working as well as it was before I started, I can divert and start adding all sorts of shiney new features to the mix, several of which have been sitting on the back burner while the basics have been in the works.

I'd like (for what little my preference is worth) to have this particular problem resolved this week so I can get moving on the rest of the work I need to do. I probably won't make it to #ps this week, but I don't have much worth reporting there anyway.


Hex

ChrisDolan on 2008-07-14T02:27:28

Look at a Java .class file in a hex editor sometime. The first 4 bytes (8 hex chars) are the magic number that identifies the file type.

Re:Hex

Whiteknight on 2008-07-14T03:02:33

Yeah, I'm familiar with Java's 0xcafebabe. It's one of the better magic numbers for binary file formats (beats 'MZ' anyday).