Author: Sam Clegg Date: 2022-05-22T19:15:19-07:00 New Revision: bce25ef66596b013cd61c322c0098f89e43e92f6
URL: https://github.com/llvm/llvm-project/commit/bce25ef66596b013cd61c322c0098f89e43e92f6 DIFF: https://github.com/llvm/llvm-project/commit/bce25ef66596b013cd61c322c0098f89e43e92f6.diff LOG: Patches from emscripten 3.1.11 Added: Modified: compiler-rt/lib/lsan/lsan_common.cpp compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp libcxx/include/__config Removed: ################################################################################ diff --git a/compiler-rt/lib/lsan/lsan_common.cpp b/compiler-rt/lib/lsan/lsan_common.cpp index b52106537a677..1a7a3d4203d4e 100644 --- a/compiler-rt/lib/lsan/lsan_common.cpp +++ b/compiler-rt/lib/lsan/lsan_common.cpp @@ -185,6 +185,14 @@ static uptr GetCallerPC(const StackTrace &stack) { // valid before reporting chunks as leaked. bool LeakSuppressionContext::SuppressInvalid(const StackTrace &stack) { uptr caller_pc = GetCallerPC(stack); +#if SANITIZER_EMSCRIPTEN + // caller_pr will always be 0 if we use malloc_context_size=0 (or 1) which + // we recommend under emscripten to save memory. It seems that this setting + // now (inadvertently?) suppreses all leaks. + // See https://reviews.llvm.org/D115319#3526676. + if (!caller_pc) + return false; +#endif // If caller_pc is unknown, this chunk may be allocated in a coroutine. Mark // it as reachable, as we can't properly report its allocation stack anyway. return !caller_pc || @@ -313,7 +321,7 @@ void ScanRangeForPointers(uptr begin, uptr end, Frontier *frontier, #if SANITIZER_EMSCRIPTEN && !defined(__EMSCRIPTEN_PTHREADS__) if (cache_begin <= pp && pp < cache_end) { LOG_POINTERS("%p: skipping because it overlaps the cache %p-%p.\n", - pp, cache_begin, cache_end); + (void*)pp, (void*)cache_begin, (void*)cache_end); continue; } #endif @@ -804,53 +812,6 @@ static int DoRecoverableLeakCheck() { void DoRecoverableLeakCheckVoid() { DoRecoverableLeakCheck(); } -<<<<<<< HEAD -======= -Suppression *LeakSuppressionContext::GetSuppressionForAddr(uptr addr) { - Suppression *s = nullptr; - - // Suppress by module name. - if (const char *module_name = - Symbolizer::GetOrInit()->GetModuleNameForPc(addr)) - if (context.Match(module_name, kSuppressionLeak, &s)) - return s; - - // Suppress by file or function name. - SymbolizedStack *frames = Symbolizer::GetOrInit()->SymbolizePC(addr); - for (SymbolizedStack *cur = frames; cur; cur = cur->next) { - if (context.Match(cur->info.function, kSuppressionLeak, &s) || - context.Match(cur->info.file, kSuppressionLeak, &s)) { - break; - } - } - frames->ClearAll(); - return s; -} - -Suppression *LeakSuppressionContext::GetSuppressionForStack( - u32 stack_trace_id) { - LazyInit(); - StackTrace stack = StackDepotGet(stack_trace_id); - for (uptr i = 0; i < stack.size; i++) { -#if SANITIZER_EMSCRIPTEN - // On Emscripten, the stack trace is the actual call site, not - // the code that would be executed after the return. - // Therefore, StackTrace::GetPreviousInstructionPc is not needed. - Suppression *s = GetSuppressionForAddr(stack.trace[i]); -#else - Suppression *s = GetSuppressionForAddr( - StackTrace::GetPreviousInstructionPc(stack.trace[i])); -#endif - if (s) { - suppressed_stacks_sorted = false; - suppressed_stacks.push_back(stack_trace_id); - return s; - } - } - return nullptr; -} - ->>>>>>> 2bbe2c4b7413 (Rebase of changed from emscripten-libs-12.0.0 onto llvmorg-13.0.0) ///// LeakReport implementation. ///// // A hard limit on the number of distinct leaks, to avoid quadratic complexity diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h index 7fa8008589b63..fee66660ba277 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h @@ -139,7 +139,7 @@ namespace __sanitizer { typedef unsigned long long uptr; typedef signed long long sptr; #else -# if (SANITIZER_WORDSIZE == 64) || SANITIZER_MAC || SANITIZER_WINDOWS +# if (SANITIZER_WORDSIZE == 64) || SANITIZER_MAC || SANITIZER_WINDOWS || SANITIZER_EMSCRIPTEN typedef unsigned long uptr; typedef signed long sptr; # else diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp index 4269fed630051..32b96dbdf96f7 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp @@ -145,11 +145,19 @@ void *MmapFixedOrDieOnFatalError(uptr fixed_addr, uptr size, const char *name) { } bool MprotectNoAccess(uptr addr, uptr size) { +#if SANITIZER_EMSCRIPTEN + return true; +#else return 0 == internal_mprotect((void*)addr, size, PROT_NONE); +#endif } bool MprotectReadOnly(uptr addr, uptr size) { +#if SANITIZER_EMSCRIPTEN + return true; +#else return 0 == internal_mprotect((void *)addr, size, PROT_READ); +#endif } #if !SANITIZER_MAC diff --git a/libcxx/include/__config b/libcxx/include/__config index dec8d499850c8..bb8d4e63d3def 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -1,6 +1,3 @@ -// XXX EMSCRIPTEN: macros that would ordinarily be added from __config_site.in -#define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS - // -*- C++ -*- //===----------------------------------------------------------------------===// // @@ -1150,8 +1147,8 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( defined(__APPLE__) || \ defined(__sun__) || \ defined(__MVS__) || \ - defined(_AIX) - defined(__EMSCRIPTEN__) || \ + defined(_AIX) || \ + defined(__EMSCRIPTEN__) # define _LIBCPP_HAS_THREAD_API_PTHREAD # elif defined(__Fuchsia__) // TODO(44575): Switch to C11 thread API when possible. _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits