[PATCH] D33858: [PDB] Fix use after free.

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 2 17:22:50 PDT 2017


zturner created this revision.

Previously MappedBlockStream owned its own BumpPtrAllocator that
it would allocate from when a read crossed a block boundary.  This
way it could still return the user a contiguous buffer of the
requested size.  However, It's not uncommon to open a stream, read
some stuff, close it, and then save the information for later.
After all, since the entire file is mapped into memory, the data
should always be available as long as the file is open.

Of course, the exception to this is when the data isn't *in* the
file, but rather in some buffer that we temporarily allocated to
present this contiguous view.  And this buffer would get destroyed
as soon as the strema was closed.

The fix here is to force the user to specify the allocator, this
way it can provide an allocator that has whatever lifetime it
chooses.


https://reviews.llvm.org/D33858

Files:
  llvm/include/llvm/DebugInfo/MSF/MappedBlockStream.h
  llvm/include/llvm/DebugInfo/PDB/Native/TpiStream.h
  llvm/lib/DebugInfo/MSF/MappedBlockStream.cpp
  llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp
  llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp
  llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
  llvm/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp
  llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp
  llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
  llvm/lib/DebugInfo/PDB/Native/TpiStream.cpp
  llvm/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp
  llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
  llvm/tools/llvm-pdbdump/YAMLOutputStyle.cpp
  llvm/tools/llvm-pdbdump/fuzzer/llvm-pdbdump-fuzzer.cpp
  llvm/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33858.101298.patch
Type: text/x-patch
Size: 33923 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170603/5b05a863/attachment.bin>


More information about the llvm-commits mailing list