[PATCH] D43834: Fix use after free in PDB linker.

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 27 16:13:20 PST 2018


zturner added a comment.

In https://reviews.llvm.org/D43834#1021341, @zturner wrote:

> In https://reviews.llvm.org/D43834#1021297, @rnk wrote:
>
> > How many bytes does a PDB session allocator end up holding? Try the debug CRT PDB, since it's the most common one. I suspect it holds a ton of temporary data that we really should throw away after closing the type server PDB.
> >
> > A different way of fixing this would be to disable the optimization that skips copying records without type indices.
> >
> > Or, why are these non-remapped records even being copied into BumpPtrAllocator memory? Why don't they come directly from the PDB's MemoryBuffer? Can we extend the life of the memory mapped PDB instead? That memory is shared with the FS cache, and is much cheaper to keep around.
>
>
> I suspect it is due to records which are discontiguous.  Whenever we encounter one of those, we have to make a copy and piece it together so that it will be contiguous.  I can confirm that the number of bytes is small though.


Yea, I confirmed it all comes from discontiguous records.  Linking llvm-xray.exe, with the patch, the main PDB allocator consumes 115,717,444 bytes.  Without the patch, the main allocator consumes 114,185,356 bytes and the type server allocator consumes 1,532,088 bytes.  So this is around 1% of total memory usage.  We can try to do funny things to lower the memory usage, but it seems simpler and less error prone to just do it this way, and the penalty is pretty small.


https://reviews.llvm.org/D43834





More information about the llvm-commits mailing list