[PATCH] D41734: [DebugInfo][PDB] Fix too many FPM blocks being written in some cases

Colden Cullen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 4 11:04:55 PST 2018


colden added a comment.

This actually took me 3-4 days to track down, but I'll try to explain as clearly as I can :)

The actual crash was in WritableMappedBlockStream::writeBytes (MappedBlockStream.cpp), the write on line 408 was failing because we were writing past the end of the buffer. The call to write the bytes came from WritableMappedBlockStream::createFpmStream, on line 370. getFpmStreamLayout had reported the number of intervals as 4 instead of 3, so we were attempting to write an extra FPM block past the end of the buffer.

If my understanding of the format is correct, the file should looks something like this:
\+-------------+-------+------+---------------+-----+---------------+
\ | Super Block | Fpm0 | Fpm1 | 4096 blocks... | Fpm | 4096 blocks... |
\+-------------+-------+------+---------------+-----+---------------+
Number of intervals should be the total number of blocks, minus reserved/non-in-use-fpm blocks (so 1 if Fpm0, 2 if Fpm1), divided by the total number of blocks per interval, which should be 4097: 1 for the leading Fpm block, and 4096 for the actual blocks.

I will admit I haven't looked at the MS algorithms, but from the LLVM PDB MSF docs page, this is what I came up with.


Repository:
  rL LLVM

https://reviews.llvm.org/D41734





More information about the llvm-commits mailing list