diff options
author | Moonchild <moonchild@palemoon.org> | 2023-08-16 07:08:19 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2023-08-16 07:08:19 +0000 |
commit | 4ddaf0f4907afa8c95eca3a04ae90af290f95b8e (patch) | |
tree | 0718566851ff969dbb9cb233fe58ca083147bfaa | |
parent | 3bb0c18a5915b789beda27598f9d578516189f90 (diff) | |
parent | ff81f4969c4c6394e9553fdcd442a5ea21e8a7b1 (diff) | |
download | uxp-4ddaf0f4907afa8c95eca3a04ae90af290f95b8e.tar.gz |
Merge pull request 'Implement Address Sanitizer for MSVC, Leak, Undefined Behavior and other debug fixes.' (#2288) from dbsoft/UXP:sanitize into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/2288
-rw-r--r-- | build/autoconf/sanitize.m4 | 40 | ||||
-rw-r--r-- | build/moz.build | 8 | ||||
-rw-r--r-- | build/moz.configure/old.configure | 2 | ||||
-rw-r--r-- | build/unix/moz.build | 3 | ||||
-rw-r--r-- | js/src/vm/Stopwatch.cpp | 6 | ||||
-rw-r--r-- | js/src/vm/Stopwatch.h | 3 | ||||
-rwxr-xr-x | media/webrtc/signaling/src/media-conduit/VideoConduit.cpp | 2 |
7 files changed, 51 insertions, 13 deletions
diff --git a/build/autoconf/sanitize.m4 b/build/autoconf/sanitize.m4 index 3193d5c624..4f038ccb6f 100644 --- a/build/autoconf/sanitize.m4 +++ b/build/autoconf/sanitize.m4 @@ -13,7 +13,7 @@ MOZ_ARG_ENABLE_BOOL(address-sanitizer, MOZ_ASAN= ) if test -n "$MOZ_ASAN"; then MOZ_LLVM_HACKS=1 - if test -n "$CLANG_CL"; then + if test "$OS_ARCH" = "WINNT"; then # Look for the ASan runtime binary if test "$CPU_ARCH" = "x86_64"; then MOZ_CLANG_RT_ASAN_LIB=clang_rt.asan_dynamic-x86_64.dll @@ -27,14 +27,14 @@ if test -n "$MOZ_ASAN"; then fi AC_SUBST(MOZ_CLANG_RT_ASAN_LIB_PATH) # Suppressing errors in recompiled code. - if test "$OS_ARCH" = "WINNT"; then + if test -n "$CLANG_CL"; then CFLAGS="-fsanitize-blacklist=$_topsrcdir/build/sanitizers/asan_blacklist_win.txt $CFLAGS" CXXFLAGS="-fsanitize-blacklist=$_topsrcdir/build/sanitizers/asan_blacklist_win.txt $CXXFLAGS" fi fi CFLAGS="-fsanitize=address $CFLAGS" CXXFLAGS="-fsanitize=address $CXXFLAGS" - if test -z "$CLANG_CL"; then + if test "$OS_ARCH" != "WINNT"; then LDFLAGS="-fsanitize=address $LDFLAGS" fi AC_DEFINE(MOZ_ASAN) @@ -80,6 +80,40 @@ if test -n "$MOZ_TSAN"; then fi AC_SUBST(MOZ_TSAN) +dnl ======================================================== +dnl = Use Leak Sanitizer +dnl ======================================================== +MOZ_ARG_ENABLE_BOOL(leak-sanitizer, +[ --enable-leak-sanitizer Enable Leak Sanitizer (default=no)], + MOZ_LSAN=1, + MOZ_LSAN= ) +if test -n "$MOZ_LSAN"; then + MOZ_LLVM_HACKS=1 + LDFLAGS="-fsanitize=leak $LDFLAGS" + AC_DEFINE(MOZ_LSAN) + MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer) +fi +AC_SUBST(MOZ_LSAN) + +dnl ======================================================== +dnl = Use Undefined Behavior Sanitizer +dnl ======================================================== +MOZ_ARG_ENABLE_BOOL(undefined-sanitizer, +[ --enable-undefined-sanitizer Enable Undefined Behavior Sanitizer (default=no)], + MOZ_UBSAN=1, + MOZ_UBSAN= ) +if test -n "$MOZ_UBSAN"; then + MOZ_LLVM_HACKS=1 + CFLAGS="-fsanitize=undefined $CFLAGS" + CXXFLAGS="-fsanitize=undefined $CXXFLAGS" + if test -z "$CLANG_CL"; then + LDFLAGS="-fsanitize=undefined $LDFLAGS" + fi + AC_DEFINE(MOZ_UBSAN) + MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer) +fi +AC_SUBST(MOZ_UBSAN) + # The LLVM symbolizer is used by all sanitizers AC_SUBST(LLVM_SYMBOLIZER) diff --git a/build/moz.build b/build/moz.build index 6567dd944c..1f1c7474cd 100644 --- a/build/moz.build +++ b/build/moz.build @@ -58,9 +58,11 @@ FINAL_TARGET_FILES += ['/.gdbinit'] FINAL_TARGET_PP_FILES += ['.gdbinit_python.in'] OBJDIR_FILES += ['!/dist/bin/.gdbinit_python'] -# Install the clang-cl runtime library for ASAN next to the binaries we produce. -if CONFIG['MOZ_ASAN'] and CONFIG['CLANG_CL']: - FINAL_TARGET_FILES += ['%' + CONFIG['MOZ_CLANG_RT_ASAN_LIB_PATH']] +# Install the clang runtime library for ASAN next to the binaries we produce. +if CONFIG['MOZ_ASAN'] and CONFIG['MOZ_CLANG_RT_ASAN_LIB_PATH']: + FINAL_TARGET_FILES += [CONFIG['MOZ_CLANG_RT_ASAN_LIB_PATH']] +if CONFIG['LLVM_SYMBOLIZER']: + FINAL_TARGET_FILES += ['/' + CONFIG['LLVM_SYMBOLIZER']] if CONFIG['MOZ_APP_BASENAME']: FINAL_TARGET_PP_FILES += ['application.ini'] diff --git a/build/moz.configure/old.configure b/build/moz.configure/old.configure index 3d3873eae8..091efc398d 100644 --- a/build/moz.configure/old.configure +++ b/build/moz.configure/old.configure @@ -197,6 +197,7 @@ def old_configure_options(*options): '--enable-ios-target', '--enable-jitspew', '--enable-js-lto', + '--enable-leak-sanitizer', '--enable-libjpeg-turbo', '--enable-libproxy', '--enable-llvm-hacks', @@ -246,6 +247,7 @@ def old_configure_options(*options): '--enable-thread-sanitizer', '--enable-trace-logging', '--enable-ui-locale', + '--enable-undefined-sanitizer', '--enable-universalchardet', '--enable-updater', '--enable-url-classifier', diff --git a/build/unix/moz.build b/build/unix/moz.build index 88c933295c..cd455b7a4d 100644 --- a/build/unix/moz.build +++ b/build/unix/moz.build @@ -9,9 +9,6 @@ if CONFIG['MOZ_LIBSTDCXX_TARGET_VERSION'] or CONFIG['MOZ_LIBSTDCXX_HOST_VERSION' if CONFIG['USE_ELF_HACK']: DIRS += ['elfhack'] -if CONFIG['LLVM_SYMBOLIZER']: - FINAL_TARGET_FILES += ['/' + CONFIG['LLVM_SYMBOLIZER']] - SDK_FILES.bin += [ 'run-mozilla.sh', ] diff --git a/js/src/vm/Stopwatch.cpp b/js/src/vm/Stopwatch.cpp index 46841b27f8..2c267d446d 100644 --- a/js/src/vm/Stopwatch.cpp +++ b/js/src/vm/Stopwatch.cpp @@ -409,7 +409,8 @@ AutoStopwatch::getCycles(JSRuntime* runtime) const cpuid_t inline AutoStopwatch::getCPU() const { -#if defined(XP_WIN) && WINVER >= _WIN32_WINNT_VISTA +// Temporary disable untested code path. Issue #2255 +#if 0 //defined(XP_WIN) && WINVER >= _WIN32_WINNT_VISTA PROCESSOR_NUMBER proc; GetCurrentProcessorNumberEx(&proc); @@ -423,7 +424,8 @@ AutoStopwatch::getCPU() const bool inline AutoStopwatch::isSameCPU(const cpuid_t& a, const cpuid_t& b) const { -#if defined(XP_WIN) && WINVER >= _WIN32_WINNT_VISTA +// Temporary disable untested code path. Issue #2255 +#if 0 //defined(XP_WIN) && WINVER >= _WIN32_WINNT_VISTA return a.group_ == b.group_ && a.number_ == b.number_; #else return true; diff --git a/js/src/vm/Stopwatch.h b/js/src/vm/Stopwatch.h index f3985c53aa..84da265a25 100644 --- a/js/src/vm/Stopwatch.h +++ b/js/src/vm/Stopwatch.h @@ -271,7 +271,8 @@ struct PerformanceMonitoring { uint64_t highestTimestampCounter_; }; -#if WINVER >= 0x0600 +// Temporary disable untested code path. Issue #2255 +#if 0 // WINVER >= 0x0600 struct cpuid_t { uint16_t group_; uint8_t number_; diff --git a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp index e6db06a685..37dcf05005 100755 --- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp +++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp @@ -105,7 +105,7 @@ WebrtcVideoConduit::~WebrtcVideoConduit() // Release AudioConduit first by dropping reference on MainThread, where it expects to be SyncTo(nullptr); - MOZ_ASSERT(!mSendStream && !mRecvStream, "Call DeleteStreams prior to ~WebrtcVideoConduit."); + MOZ_ASSERT(!mPtrViEBase, "Call DeleteStreams prior to ~WebrtcVideoConduit."); } bool WebrtcVideoConduit::SetLocalSSRC(unsigned int ssrc) |