diff --git a/memory/build/malloc_decls.h b/memory/build/malloc_decls.h index 8d001e3005e5..36154065d3fa 100644 --- a/memory/build/malloc_decls.h +++ b/memory/build/malloc_decls.h @@ -112,12 +112,6 @@ MALLOC_DECL(jemalloc_thread_local_arena, void, bool) // Provide information about any allocation enclosing the given address. MALLOC_DECL(jemalloc_ptr_info, void, const void*, jemalloc_ptr_info_t*) - -// If jemalloc is currently doing something on this thread then this will return -// true. This is for signal handlers, if jemalloc causes a segfault during free -// (or realloc etc) then this can tell the signal handler that the crashing -// address isn't useful for something like PHC. -MALLOC_DECL(jemalloc_is_working, bool) # endif # if MALLOC_FUNCS & MALLOC_FUNCS_ARENA_BASE diff --git a/memory/build/mozjemalloc.cpp b/memory/build/mozjemalloc.cpp index 12836718e75c..c780a17c5fd0 100644 --- a/memory/build/mozjemalloc.cpp +++ b/memory/build/mozjemalloc.cpp @@ -3651,27 +3651,6 @@ MOZ_NEVER_INLINE jemalloc_ptr_info_t* jemalloc_ptr_info(const void* aPtr) { } } // namespace Debug -// Used in crash reporting to query what pointer jemalloc was working on when it -// crashed. -static MOZ_THREAD_LOCAL(unsigned) gWorkingCount; - -struct MOZ_RAII AutoSetWorking { - explicit AutoSetWorking() { gWorkingCount.set(gWorkingCount.get() + 1); } - - AutoSetWorking(const AutoSetWorking&) = delete; - AutoSetWorking(AutoSetWorking&&) = delete; - - ~AutoSetWorking() { - MOZ_ASSERT(gWorkingCount.get()); - gWorkingCount.set(gWorkingCount.get() - 1); - } -}; - -template <> -inline bool MozJemalloc::jemalloc_is_working() { - return !!gWorkingCount.get(); -} - arena_chunk_t* arena_t::DallocSmall(arena_chunk_t* aChunk, void* aPtr, arena_chunk_map_t* aMapElm) { arena_run_t* run; @@ -3757,8 +3736,6 @@ static inline void arena_dalloc(void* aPtr, size_t aOffset, arena_t* aArena) { MOZ_ASSERT(aOffset != 0); MOZ_ASSERT(GetChunkOffsetForPtr(aPtr) == aOffset); - AutoSetWorking auto_working; - auto chunk = (arena_chunk_t*)((uintptr_t)aPtr - aOffset); auto arena = chunk->arena; MOZ_ASSERT(arena); @@ -4302,7 +4279,6 @@ static bool malloc_init_hard() { if (!thread_arena.init()) { return true; } - MOZ_ASSERT(gWorkingCount.init()); // Get page size and number of CPUs const size_t result = GetKernelPageSize(); @@ -4567,7 +4543,6 @@ inline void* BaseAllocator::realloc(void* aPtr, size_t aSize) { if (aPtr) { MOZ_RELEASE_ASSERT(malloc_initialized); - AutoSetWorking auto_working; auto info = AllocInfo::Get(aPtr); auto arena = info.Arena(); @@ -4674,7 +4649,6 @@ inline size_t MozJemalloc::malloc_good_size(size_t aSize) { template <> inline size_t MozJemalloc::malloc_usable_size(usable_ptr_t aPtr) { - AutoSetWorking auto_working; return AllocInfo::GetValidated(aPtr).Size(); } diff --git a/toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.cc b/toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.cc index 521f2308252a..b98946ea6778 100644 --- a/toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.cc +++ b/toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.cc @@ -102,7 +102,6 @@ #endif #ifdef MOZ_PHC -#include "mozmemory.h" #include "replace_malloc_bridge.h" #endif @@ -468,19 +467,13 @@ static void GetPHCAddrInfo(siginfo_t* siginfo, // Runs on the crashing thread. bool ExceptionHandler::HandleSignal(int /*sig*/, siginfo_t* info, void* uc) { mozilla::phc::AddrInfo* addr_info = nullptr; - #ifdef MOZ_PHC - if (!jemalloc_is_working()) { - // If jemalloc crashed then the PHC information is invalid. Only retrive - // it when we know its valid. - addr_info = &mozilla::phc::gAddrInfo; - GetPHCAddrInfo(info, addr_info); - } + addr_info = &mozilla::phc::gAddrInfo; + GetPHCAddrInfo(info, addr_info); #endif - if (filter_ && !filter_(callback_context_)) { + if (filter_ && !filter_(callback_context_)) return false; - } // Allow ourselves to be dumped if the signal is trusted. bool signal_trusted = info->si_code > 0; diff --git a/toolkit/crashreporter/breakpad-client/mac/handler/exception_handler.cc b/toolkit/crashreporter/breakpad-client/mac/handler/exception_handler.cc index 0d640fe5b1ba..eec6f9b9cc13 100644 --- a/toolkit/crashreporter/breakpad-client/mac/handler/exception_handler.cc +++ b/toolkit/crashreporter/breakpad-client/mac/handler/exception_handler.cc @@ -43,7 +43,6 @@ #include "mozilla/Assertions.h" #ifdef MOZ_PHC -#include "mozmemory.h" #include "replace_malloc_bridge.h" #endif @@ -445,12 +444,8 @@ bool ExceptionHandler::WriteMinidumpWithException( mozilla::phc::AddrInfo* addr_info = nullptr; #ifdef MOZ_PHC - if (!jemalloc_is_working()) { - // If jemalloc crashed then the PHC information is invalid. Only retrive - // it when we know its valid. - addr_info = &mozilla::phc::gAddrInfo; - GetPHCAddrInfo(exception_type, exception_subcode, addr_info); - } + addr_info = &mozilla::phc::gAddrInfo; + GetPHCAddrInfo(exception_type, exception_subcode, addr_info); #endif if (directCallback_) { @@ -458,18 +453,17 @@ bool ExceptionHandler::WriteMinidumpWithException( exception_type, exception_code, exception_subcode, - thread_name) && - exit_after_write) { - _exit(exception_type); + thread_name) ) { + if (exit_after_write) + _exit(exception_type); } #if !TARGET_OS_IPHONE } else if (IsOutOfProcess()) { if (exception_type && exception_code) { // If this is a real exception, give the filter (if any) a chance to // decide if this should be sent. - if (filter_ && !filter_(callback_context_)) { + if (filter_ && !filter_(callback_context_)) return false; - } result = crash_generation_client_->RequestDumpForException( exception_type, exception_code, @@ -500,9 +494,8 @@ bool ExceptionHandler::WriteMinidumpWithException( if (exception_type && exception_code) { // If this is a real exception, give the filter (if any) a chance to // decide if this should be sent. - if (filter_ && !filter_(callback_context_)) { + if (filter_ && !filter_(callback_context_)) return false; - } md.SetExceptionInformation(exception_type, exception_code, exception_subcode, thread_name); @@ -518,8 +511,9 @@ bool ExceptionHandler::WriteMinidumpWithException( // If the user callback returned true and we're handling an exception // (rather than just writing out the file), then we should exit without // forwarding the exception to the next handler. - if (result && exit_after_write) { - _exit(exception_type); + if (result) { + if (exit_after_write) + _exit(exception_type); } } } diff --git a/toolkit/crashreporter/breakpad-client/windows/handler/exception_handler.cc b/toolkit/crashreporter/breakpad-client/windows/handler/exception_handler.cc index e6ee779c2ca0..2e6bfe4a994a 100644 --- a/toolkit/crashreporter/breakpad-client/windows/handler/exception_handler.cc +++ b/toolkit/crashreporter/breakpad-client/windows/handler/exception_handler.cc @@ -40,7 +40,6 @@ #include "common/windows/guid_string.h" #ifdef MOZ_PHC -#include "mozmemory.h" #include "replace_malloc_bridge.h" #endif @@ -910,18 +909,12 @@ static void GetPHCAddrInfo(EXCEPTION_POINTERS* exinfo, #endif ExceptionHandler::MinidumpResult ExceptionHandler::WriteMinidumpWithException( - DWORD requesting_thread_id, - EXCEPTION_POINTERS* exinfo, - MDRawAssertionInfo* assertion) -{ + DWORD requesting_thread_id, EXCEPTION_POINTERS* exinfo, + MDRawAssertionInfo* assertion) { mozilla::phc::AddrInfo* addr_info = nullptr; #ifdef MOZ_PHC - if (!jemalloc_is_working()) { - // If jemalloc crashed then the PHC information is invalid. Only retrive - // it when we know its valid. - addr_info = &mozilla::phc::gAddrInfo; - GetPHCAddrInfo(exinfo, addr_info); - } + addr_info = &mozilla::phc::gAddrInfo; + GetPHCAddrInfo(exinfo, addr_info); #endif // Give user code a chance to approve or prevent writing a minidump. If the