diff options
-rw-r--r-- | gyp/common_conditions.gypi | 3 | ||||
-rw-r--r-- | src/codec/SkJpegCodec.cpp | 13 | ||||
-rw-r--r-- | src/images/SkImageDecoder_libjpeg.cpp | 4 | ||||
-rw-r--r-- | src/opts/SkXfermode_opts.h | 14 | ||||
-rw-r--r-- | tools/dm_flags.json | 322 | ||||
-rwxr-xr-x | tools/dm_flags.py | 25 |
6 files changed, 371 insertions, 10 deletions
diff --git a/gyp/common_conditions.gypi b/gyp/common_conditions.gypi index 859577e1a3..1f90d6f9f1 100644 --- a/gyp/common_conditions.gypi +++ b/gyp/common_conditions.gypi @@ -451,6 +451,9 @@ [ 'skia_sanitizer == "thread"', { 'defines': [ 'THREAD_SANITIZER' ], }], + [ 'skia_sanitizer == "memory"', { + 'cflags': [ '-fsanitize-memory-track-origins' ], + }], ], }], [ 'skia_clang_build', { diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp index 112078b97c..aefe264f1a 100644 --- a/src/codec/SkJpegCodec.cpp +++ b/src/codec/SkJpegCodec.cpp @@ -6,6 +6,7 @@ */ #include "SkCodec.h" +#include "SkMSAN.h" #include "SkJpegCodec.h" #include "SkJpegDecoderMgr.h" #include "SkJpegUtility_codec.h" @@ -215,7 +216,7 @@ bool SkJpegCodec::setOutputColorSpace(const SkImageInfo& dst) { } /* - * Checks if we can natively scale to the requested dimensions and natively scales the + * Checks if we can natively scale to the requested dimensions and natively scales the * dimensions if possible */ bool SkJpegCodec::onDimensionsSupported(const SkISize& size) { @@ -308,6 +309,7 @@ SkCodec::Result SkJpegCodec::onGetPixels(const SkImageInfo& dstInfo, for (uint32_t y = 0; y < dstHeight; y++) { // Read rows of the image uint32_t lines = jpeg_read_scanlines(dinfo, &dstRow, 1); + sk_msan_mark_initialized(dstRow, dstRow + dstRowBytes, "skbug.com/4550"); // If we cannot read enough rows, assume the input is incomplete if (lines != 1) { @@ -399,24 +401,27 @@ SkCodec::Result SkJpegCodec::onStartScanlineDecode(const SkImageInfo& dstInfo, return kSuccess; } -int SkJpegCodec::onGetScanlines(void* dst, int count, size_t rowBytes) { +int SkJpegCodec::onGetScanlines(void* dst, int count, size_t dstRowBytes) { // Set the jump location for libjpeg errors if (setjmp(fDecoderMgr->getJmpBuf())) { return fDecoderMgr->returnFailure("setjmp", kInvalidInput); } // Read rows one at a time JSAMPLE* dstRow; + size_t srcRowBytes = get_row_bytes(fDecoderMgr->dinfo()); if (fSwizzler) { // write data to storage row, then sample using swizzler dstRow = fSrcRow; } else { // write data directly to dst + SkASSERT(count == 1 || dstRowBytes >= srcRowBytes); dstRow = (JSAMPLE*) dst; } for (int y = 0; y < count; y++) { // Read row of the image uint32_t rowsDecoded = jpeg_read_scanlines(fDecoderMgr->dinfo(), &dstRow, 1); + sk_msan_mark_initialized(dstRow, dstRow + srcRowBytes, "skbug.com/4550"); if (rowsDecoded != 1) { fDecoderMgr->dinfo()->output_scanline = this->dstInfo().height(); return y; @@ -425,9 +430,9 @@ int SkJpegCodec::onGetScanlines(void* dst, int count, size_t rowBytes) { if (fSwizzler) { // use swizzler to sample row fSwizzler->swizzle(dst, dstRow); - dst = SkTAddOffset<JSAMPLE>(dst, rowBytes); + dst = SkTAddOffset<JSAMPLE>(dst, dstRowBytes); } else { - dstRow = SkTAddOffset<JSAMPLE>(dstRow, rowBytes); + dstRow = SkTAddOffset<JSAMPLE>(dstRow, dstRowBytes); } } return count; diff --git a/src/images/SkImageDecoder_libjpeg.cpp b/src/images/SkImageDecoder_libjpeg.cpp index 6a3ae87b6a..89bfefcd45 100644 --- a/src/images/SkImageDecoder_libjpeg.cpp +++ b/src/images/SkImageDecoder_libjpeg.cpp @@ -509,6 +509,8 @@ SkImageDecoder::Result SkJPEGImageDecoder::onDecode(SkStream* stream, SkBitmap* for (int y = 0;; y++) { JSAMPLE* rowptr = (JSAMPLE*)srcRow; int row_count = jpeg_read_scanlines(&cinfo, &rowptr, 1); + sk_msan_mark_initialized(srcRow, srcRow + cinfo.output_width * srcBytesPerPixel, + "skbug.com/4550"); if (0 == row_count) { // if row_count == 0, then we didn't get a scanline, // so return early. We will return a partial image. @@ -525,8 +527,6 @@ SkImageDecoder::Result SkJPEGImageDecoder::onDecode(SkStream* stream, SkBitmap* convert_CMYK_to_RGB(srcRow, cinfo.output_width); } - sk_msan_mark_initialized(srcRow, srcRow + cinfo.output_width * srcBytesPerPixel, - "skbug.com/4550"); sampler.next(srcRow); if (bm->height() - 1 == y) { diff --git a/src/opts/SkXfermode_opts.h b/src/opts/SkXfermode_opts.h index f15094c98b..31817f5f61 100644 --- a/src/opts/SkXfermode_opts.h +++ b/src/opts/SkXfermode_opts.h @@ -9,6 +9,7 @@ #define Sk4pxXfermode_DEFINED #include "Sk4px.h" +#include "SkMSAN.h" #include "SkNx.h" #include "SkXfermode_proccoeff.h" @@ -202,6 +203,17 @@ XFERMODE_AA(Plus) { // [ clamp( (1-AA)D + (AA)(S+D) ) == clamp(D + AA*S) ] #undef XFERMODE_AA +// Src and Clear modes are safe to use with unitialized dst buffers, +// even if the implementation branches based on bytes from dst (e.g. asserts in Debug mode). +// For those modes, just lie to MSAN that dst is always intialized. +template <typename Xfermode> static void mark_dst_initialized_if_safe(void*, void*) {} +template <> void mark_dst_initialized_if_safe<Src>(void* dst, void* end) { + sk_msan_mark_initialized(dst, end, "Src doesn't read dst."); +} +template <> void mark_dst_initialized_if_safe<Clear>(void* dst, void* end) { + sk_msan_mark_initialized(dst, end, "Clear doesn't read dst."); +} + template <typename Xfermode> class Sk4pxXfermode : public SkProcCoeffXfermode { public: @@ -209,6 +221,7 @@ public: : INHERITED(rec, mode) {} void xfer32(SkPMColor dst[], const SkPMColor src[], int n, const SkAlpha aa[]) const override { + mark_dst_initialized_if_safe<Xfermode>(dst, dst+n); if (nullptr == aa) { Sk4px::MapDstSrc(n, dst, src, Xfermode()); } else { @@ -217,6 +230,7 @@ public: } void xfer16(uint16_t dst[], const SkPMColor src[], int n, const SkAlpha aa[]) const override { + mark_dst_initialized_if_safe<Xfermode>(dst, dst+n); SkPMColor dst32[4]; while (n >= 4) { dst32[0] = SkPixel16ToPixel32(dst[0]); diff --git a/tools/dm_flags.json b/tools/dm_flags.json index 4e1c612aa6..834c177a52 100644 --- a/tools/dm_flags.json +++ b/tools/dm_flags.json @@ -1739,6 +1739,328 @@ "_", "image-cacherator-from-ctable" ], + "Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-MSAN": [ + "--pre_log", + "--matrix", + "0", + "1", + "1", + "0", + "--config", + "565", + "8888", + "gpu", + "upright-matrix-8888", + "upright-matrix-gpu", + "sp-8888", + "twice-8888", + "2ndpic-8888", + "remote-8888", + "remote_cache-8888", + "msaa16", + "pdf", + "pdf_poppler", + "serialize-8888", + "tiles_rt-8888", + "pic-8888", + "--src", + "tests", + "gm", + "image", + "--blacklist", + "_", + "image", + "_", + "interlaced1.png", + "_", + "image", + "_", + "interlaced2.png", + "_", + "image", + "_", + "interlaced3.png", + "serialize-8888", + "gm", + "_", + "not_native32_bitmap_config", + "serialize-8888", + "gm", + "_", + "bleed_image", + "serialize-8888", + "gm", + "_", + "bleed_alpha_image", + "serialize-8888", + "gm", + "_", + "bleed_alpha_image_shader", + "serialize-8888", + "gm", + "_", + "blend", + "serialize-8888", + "gm", + "_", + "c_gms", + "serialize-8888", + "gm", + "_", + "colortype", + "serialize-8888", + "gm", + "_", + "colortype_xfermodes", + "serialize-8888", + "gm", + "_", + "colorwheelnative", + "serialize-8888", + "gm", + "_", + "drawfilter", + "serialize-8888", + "gm", + "_", + "fontmgr_bounds_0.75_0", + "serialize-8888", + "gm", + "_", + "fontmgr_bounds_1_-0.25", + "serialize-8888", + "gm", + "_", + "fontmgr_bounds", + "serialize-8888", + "gm", + "_", + "fontmgr_match", + "serialize-8888", + "gm", + "_", + "fontmgr_iter", + "serialize-8888", + "gm", + "_", + "lightingshader", + "serialize-8888", + "gm", + "_", + "localmatriximagefilter", + "serialize-8888", + "gm", + "_", + "path_stroke_with_zero_length", + "serialize-8888", + "gm", + "_", + "textblobgeometrychange", + "serialize-8888", + "gm", + "_", + "verylargebitmap", + "serialize-8888", + "gm", + "_", + "verylarge_picture_image", + "sp-8888", + "gm", + "_", + "blend", + "pic-8888", + "gm", + "_", + "blend", + "2ndpic-8888", + "gm", + "_", + "blend", + "sp-8888", + "gm", + "_", + "drawfilter", + "pic-8888", + "gm", + "_", + "drawfilter", + "2ndpic-8888", + "gm", + "_", + "drawfilter", + "sp-8888", + "gm", + "_", + "path_stroke_with_zero_length", + "pic-8888", + "gm", + "_", + "path_stroke_with_zero_length", + "2ndpic-8888", + "gm", + "_", + "path_stroke_with_zero_length", + "sp-8888", + "gm", + "_", + "textblobgeometrychange", + "pic-8888", + "gm", + "_", + "textblobgeometrychange", + "2ndpic-8888", + "gm", + "_", + "textblobgeometrychange", + "sp-8888", + "gm", + "_", + "patch_primitive", + "sp-8888", + "gm", + "_", + "image-cacherator-from-picture", + "pic-8888", + "gm", + "_", + "image-cacherator-from-picture", + "2ndpic-8888", + "gm", + "_", + "image-cacherator-from-picture", + "serialize-8888", + "gm", + "_", + "image-cacherator-from-picture", + "sp-8888", + "gm", + "_", + "image-cacherator-from-raster", + "pic-8888", + "gm", + "_", + "image-cacherator-from-raster", + "2ndpic-8888", + "gm", + "_", + "image-cacherator-from-raster", + "serialize-8888", + "gm", + "_", + "image-cacherator-from-raster", + "sp-8888", + "gm", + "_", + "image-cacherator-from-ctable", + "pic-8888", + "gm", + "_", + "image-cacherator-from-ctable", + "2ndpic-8888", + "gm", + "_", + "image-cacherator-from-ctable", + "serialize-8888", + "gm", + "_", + "image-cacherator-from-ctable", + "_", + "image", + "_", + ".arw", + "_", + "image", + "_", + ".cr2", + "_", + "image", + "_", + ".dng", + "_", + "image", + "_", + ".nef", + "_", + "image", + "_", + ".nrw", + "_", + "image", + "_", + ".orf", + "_", + "image", + "_", + ".raf", + "_", + "image", + "_", + ".rw2", + "_", + "image", + "_", + ".pef", + "_", + "image", + "_", + ".srw", + "_", + "image", + "_", + ".ARW", + "_", + "image", + "_", + ".CR2", + "_", + "image", + "_", + ".DNG", + "_", + "image", + "_", + ".NEF", + "_", + "image", + "_", + ".NRW", + "_", + "image", + "_", + ".ORF", + "_", + "image", + "_", + ".RAF", + "_", + "image", + "_", + ".RW2", + "_", + "image", + "_", + ".PEF", + "_", + "image", + "_", + ".SRW", + "_", + "image", + "_", + ".wbmp", + "_", + "image", + "_", + ".png", + "_", + "image", + "_", + ".bmp", + "--match", + "~Codec", + "~BlurLargeImage", + "~FontMgrAndroidParser" + ], "Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-TSAN": [ "--pre_log", "--matrix", diff --git a/tools/dm_flags.py b/tools/dm_flags.py index beb3085b84..ab8a37e5fe 100755 --- a/tools/dm_flags.py +++ b/tools/dm_flags.py @@ -166,10 +166,6 @@ def get_args(bot): for raw_ext in r: blacklist.extend(('_ image _ .%s' % raw_ext).split(' ')) - if blacklist: - args.append('--blacklist') - args.extend(blacklist) - match = [] if 'Valgrind' in bot: # skia:3021 match.append('~Threaded') @@ -193,6 +189,26 @@ def get_args(bot): if 'ANGLE' in bot and 'Debug' in bot: match.append('~GLPrograms') # skia:4717 + # Hacking around trying to get the MSAN bot green. + if 'MSAN' in bot: + # S32A_Opaque_BlitRow32_SSE4's sk_msan_assert_initialized failing on .SRW. + r = ["arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw", + "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW"] + for raw_ext in r: + blacklist.extend(('_ image _ .%s' % raw_ext).split(' ')) + + blacklist.extend(('_ image _ .wbmp').split(' ')) # skia:4900 + blacklist.extend(('_ image _ .png').split(' ')) # I8 .png color tables + blacklist.extend(('_ image _ .bmp').split(' ')) # I8 .bmp color tables + + match.append('~Codec') # Uninitialzied memory used in PIEX. + match.append('~BlurLargeImage') # Bug in the GM? + match.append('~FontMgrAndroidParser') # expat currently uninstrumented. + + if blacklist: + args.append('--blacklist') + args.extend(blacklist) + if match: args.append('--match') args.extend(match) @@ -213,6 +229,7 @@ def self_test(): 'Test-Android-GCC-Nexus7-GPU-Tegra3-Arm7-Release', 'Test-Android-GCC-NexusPlayer-CPU-SSSE3-x86-Release', 'Test-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind', + 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-MSAN', 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-TSAN', 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Valgrind', 'Test-Win7-MSVC-ShuttleA-GPU-HD2000-x86-Debug-ANGLE', |