jasonwhite / ducible

A tool to make Windows builds reproducible. (UNMAINTAINED)
MIT License
257 stars 24 forks source link

msf: don't put free page map blocks in a stream's list of blocks #14

Closed evetsso closed 6 years ago

evetsso commented 6 years ago

I have a large pdb that was getting corrupted by ducible. Even pdbdump would complain about the corruption after ducible was done processing it.

Basically my pdb has a stream in it that is long enough that it would be interrupted by a FPM block, and can't be stored contiguously in the pdb file. But ducible was trying anyway:

Stream Table
============
    0:        0 bytes,    0 pages []
    1:      118 bytes,    1 pages [4 (0x4000-0x4fff)]
    2: 22279604 bytes, 5440 pages [5-5444 (0x5000-0x1544fff)]
...

AIUI, it shouldn't be possible for such a large contiguous stream to exist in a pdb file, and the original file seemed to show this:

Stream Table
============
    0:       40 bytes,    1 pages [8 (0x8000-0x8fff)]
    1:      118 bytes,    1 pages [16714 (0x414a000-0x414afff)]
    2: 22279604 bytes, 5440 pages [18819 (0x4983000-0x4983fff), 10985-12288 (0x2ae9000-0x3000fff), 12291-16384 (0x3003000-0x4000fff), 16387-16427 (0x4003000-0x402bfff)]
...

It looked like the free page map blocks were getting included in the stream's block list, which messed everything up. It seems that the FPM blocks are implicit and don't need to be written into any stream's block list.

This change fixes things for me, but I don't claim to fully understand everything about the code or the file format.

This tool is awesome! Thanks for developing it!

jasonwhite commented 6 years ago

Great find! I guess I hadn't tested this on any PDBs that had large enough streams. I found myself a 2 GB PDB and verified your fix.

Thanks for the PR and the detailed explanation!

I'll merge this and make a new release.

jasonwhite commented 6 years ago

New release published: https://github.com/jasonwhite/ducible/releases/tag/v1.2.1

Thanks again!