[llvm] r180094 - Tell MSan that memory initialized by libz is valid
Nick Lewycky
nicholas at mxc.ca
Thu Apr 25 11:06:59 PDT 2013
On 04/23/2013 05:17 AM, Alexey Samsonov wrote:
> Author: samsonov
> Date: Tue Apr 23 07:17:46 2013
> New Revision: 180094
>
> URL: http://llvm.org/viewvc/llvm-project?rev=180094&view=rev
> Log:
> Tell MSan that memory initialized by libz is valid
Why doesn't msan instrument this correctly? Or is libz not initializing
all this memory?
Nick
>
> Modified:
> llvm/trunk/lib/Support/Compression.cpp
>
> Modified: llvm/trunk/lib/Support/Compression.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Compression.cpp?rev=180094&r1=180093&r2=180094&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Support/Compression.cpp (original)
> +++ llvm/trunk/lib/Support/Compression.cpp Tue Apr 23 07:17:46 2013
> @@ -15,6 +15,7 @@
> #include "llvm/ADT/OwningPtr.h"
> #include "llvm/ADT/StringRef.h"
> #include "llvm/Config/config.h"
> +#include "llvm/Support/Compiler.h"
> #include "llvm/Support/ErrorHandling.h"
> #include "llvm/Support/MemoryBuffer.h"
> #if LLVM_ENABLE_ZLIB == 1&& HAVE_ZLIB_H
> @@ -55,9 +56,12 @@ zlib::Status zlib::compress(StringRef In
> Status Res = encodeZlibReturnValue(::compress2(
> (Bytef *)TmpBuffer.get(),&CompressedSize,
> (const Bytef *)InputBuffer.data(), InputBuffer.size(), CLevel));
> - if (Res == StatusOK)
> + if (Res == StatusOK) {
> CompressedBuffer.reset(MemoryBuffer::getMemBufferCopy(
> StringRef(TmpBuffer.get(), CompressedSize)));
> + // Tell MSan that memory initialized by zlib is valid.
> + __msan_unpoison(CompressedBuffer.data(), CompressedBuffer.size());
> + }
> return Res;
> }
>
> @@ -68,9 +72,12 @@ zlib::Status zlib::uncompress(StringRef
> Status Res = encodeZlibReturnValue(
> ::uncompress((Bytef *)TmpBuffer.get(), (uLongf *)&UncompressedSize,
> (const Bytef *)InputBuffer.data(), InputBuffer.size()));
> - if (Res == StatusOK)
> + if (Res == StatusOK) {
> UncompressedBuffer.reset(MemoryBuffer::getMemBufferCopy(
> StringRef(TmpBuffer.get(), UncompressedSize)));
> + // Tell MSan that memory initialized by zlib is valid.
> + __msan_unpoison(UncompressedBuffer.data(), UncompressedBuffer.size());
> + }
> return Res;
> }
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
More information about the llvm-commits
mailing list