From 7002484fd4dbd21e1a533b33329281dcb7e39115 Mon Sep 17 00:00:00 2001 From: bungeman Date: Fri, 12 Jun 2020 01:50:15 -0400 Subject: [PATCH] [skia] Build fix for upstream build changes. (#3967) * [skia] Update diff for upstream change. SkReadBuffer::getArrayCount() implementation changed, so update the diff. * [skia] Build fix for upstream build changes. Skia is changing its build a little bit. 'skia_enable_fontmgr_custom' has become 'skia_enable_fontmgr_custom_directory' (since that is what it actually did) and skia_enable_fontmgr_custom_embedded has been added. * [skia] Update SwiftShader to something not so old. Skia builds it without submodules. Only build libGLESv2 and libEGL instead of building everything, which isn't needed and takes a long time. SwiftShader already has a checked-in build/ directory, so use a different directory for building. Limit the number of make jobs to avoid 'Cannot allocate memory' errors. To build SwiftShader with a sanitizer, the cmake define is now like SWIFTSHADER_XSAN. --- projects/skia/Dockerfile | 3 +-- projects/skia/build.sh | 21 ++++++++++++--------- projects/skia/skia.diff | 10 ++++++---- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/projects/skia/Dockerfile b/projects/skia/Dockerfile index 801c543b6..53c613166 100644 --- a/projects/skia/Dockerfile +++ b/projects/skia/Dockerfile @@ -34,8 +34,7 @@ RUN bin/sync WORKDIR $SRC/skia/third_party/externals/swiftshader/ # TODO(metzman): Come up with a better long term solution, such as downloading # prebuilt libraries, than pinning swiftshader to a known working revision. -RUN git checkout bf8fd5b5fb6892dabcc21b4b86d41cd40cb9b4b5 -RUN git submodule update --init +RUN git checkout 45510ad8a77862c1ce2e33f0efed41544f5f048b WORKDIR $SRC/skia RUN wget -O $SRC/skia/image_filter_deserialize_seed_corpus.zip https://storage.googleapis.com/skia-fuzzer/oss-fuzz/image_filter_deserialize_seed_corpus.zip diff --git a/projects/skia/build.sh b/projects/skia/build.sh index fbbf2ab46..cfc22cda4 100644 --- a/projects/skia/build.sh +++ b/projects/skia/build.sh @@ -18,26 +18,27 @@ # Build SwiftShader pushd third_party/externals/swiftshader/ export SWIFTSHADER_INCLUDE_PATH=$PWD/include -rm -rf build -mkdir build +# SwiftShader already has a build/ directory, use something else +rm -rf build_swiftshader +mkdir build_swiftshader -cd build +cd build_swiftshader if [ $SANITIZER == "coverage" ]; then cmake .. else if [ $SANITIZER == "address" ]; then - CMAKE_SANITIZER="ASAN" + CMAKE_SANITIZER="SWIFTSHADER_ASAN" elif [ $SANITIZER == "memory" ]; then - CMAKE_SANITIZER="MSAN" + CMAKE_SANITIZER="SWIFTSHADER_MSAN" elif [ $SANITIZER == "undefined" ]; then - CMAKE_SANITIZER="UBSAN" + CMAKE_SANITIZER="SWIFTSHADER_UBSAN" else exit 1 fi CFLAGS= CXXFLAGS="-stdlib=libc++" cmake .. -D$CMAKE_SANITIZER=1 fi -make -j +make -j2 libGLESv2 libEGL cp libGLESv2.so libEGL.so $OUT export SWIFTSHADER_LIB_PATH=$OUT @@ -67,7 +68,8 @@ $SRC/depot_tools/gn gen out/Fuzz\ extra_cflags_c=["'"$CFLAGS_ARR"'"] extra_cflags_cc=["'"$CXXFLAGS_ARR"'"] extra_ldflags=["'"$LDFLAGS_ARR"'"] - skia_enable_fontmgr_custom=false + skia_enable_fontmgr_custom_directory=false + skia_enable_fontmgr_custom_embedded=false skia_enable_fontmgr_custom_empty=true skia_enable_gpu=true skia_enable_skottie=true @@ -84,7 +86,8 @@ $SRC/depot_tools/gn gen out/Fuzz_mem_constraints\ extra_cflags_c=["'"$CFLAGS_ARR"'"] extra_cflags_cc=["'"$CXXFLAGS_ARR"'","-DIS_FUZZING"] extra_ldflags=["'"$LDFLAGS_ARR"'"] - skia_enable_fontmgr_custom=false + skia_enable_fontmgr_custom_directory=false + skia_enable_fontmgr_custom_embedded=false skia_enable_fontmgr_custom_empty=true skia_enable_gpu=true skia_enable_skottie=true diff --git a/projects/skia/skia.diff b/projects/skia/skia.diff index 9d4776628..0a7354ca9 100644 --- a/projects/skia/skia.diff +++ b/projects/skia/skia.diff @@ -134,15 +134,17 @@ diff --git a/src/core/SkReadBuffer.cpp b/src/core/SkReadBuffer.cpp index c7e26df8d4..eb9b28141d 100644 --- a/src/core/SkReadBuffer.cpp +++ b/src/core/SkReadBuffer.cpp -@@ -277,7 +277,12 @@ sk_sp SkReadBuffer::readByteArrayAsData() { +@@ -299,8 +299,13 @@ sk_sp SkReadBuffer::readByteArrayAsData() { uint32_t SkReadBuffer::getArrayCount() { const size_t inc = sizeof(uint32_t); - fError = fError || !IsPtrAlign4(fReader.peek()) || !fReader.isAvailable(inc); + if (!this->validate(IsPtrAlign4(fCurr) && this->isAvailable(inc))) { + return 0; + } +#if defined(IS_FUZZING) -+ uint32_t retVal = fError ? 0 : *(uint32_t*)fReader.peek(); ++ uint32_t retVal = *(uint32_t*)fCurr; + return retVal < 1000 ? retVal: 1000; +#else - return fError ? 0 : *(uint32_t*)fReader.peek(); + return *((uint32_t*)fCurr); +#endif }