[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.
This commit is contained in:
bungeman 2020-06-12 01:50:15 -04:00 committed by GitHub
parent 26e8d7c772
commit 7002484fd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 15 deletions

View File

@ -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

View File

@ -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

View File

@ -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<SkData> SkReadBuffer::readByteArrayAsData() {
@@ -299,8 +299,13 @@ sk_sp<SkData> 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
}