Bug 1836225 - Prevent stack walking deadlock on Windows aarch64. r=handyman,florian

On Windows aarch64 and x64 builds, stack walking relies on
RtlLookupFunctionEntry. This can lead to deadlock, which we avoid in x64
builds by adding stack walking suppressions. We must do the same in
aarch64 builds to avoid the same deadlock situation, but we are
missing some stack walk suppression paths. Let's fix that.

Differential Revision: https://phabricator.services.mozilla.com/D181435
This commit is contained in:
Yannis Juglaret 2023-09-13 14:32:50 +00:00
Родитель 6086cf951e
Коммит 33453c44ab
6 изменённых файлов: 9 добавлений и 9 удалений

Просмотреть файл

@ -293,7 +293,7 @@ static void PlatformInit(PSLockRef aLock) {}
PopulateRegsFromContext(regs, &context);
#endif
#if defined(GP_PLAT_amd64_windows)
#if defined(GP_PLAT_amd64_windows) || defined(GP_PLAT_arm64_windows)
static WindowsDllInterceptor NtDllIntercept;
typedef NTSTATUS(NTAPI* LdrUnloadDll_func)(HMODULE module);
@ -338,7 +338,7 @@ MFBT_API void InitializeWin64ProfilerHooks() {
stub_LdrResolveDelayLoadedAPI.Set(NtDllIntercept, "LdrResolveDelayLoadedAPI",
&patched_LdrResolveDelayLoadedAPI);
}
#endif // defined(GP_PLAT_amd64_windows)
#endif // defined(GP_PLAT_amd64_windows) || defined(GP_PLAT_arm64_windows)
} // namespace baseprofiler
} // namespace mozilla

Просмотреть файл

@ -3071,7 +3071,7 @@ static void locked_profiler_start(PSLockRef aLock, PowerOfTwo32 aCapacity,
mozilla::base_profiler_markers_detail::EnsureBufferForMainThreadAddMarker();
#if defined(GP_PLAT_amd64_windows)
#if defined(GP_PLAT_amd64_windows) || defined(GP_PLAT_arm64_windows)
InitializeWin64ProfilerHooks();
#endif

Просмотреть файл

@ -29,6 +29,6 @@ void DesuppressStackWalking();
MFBT_API void RegisterJitCodeRegion(uint8_t* aStart, size_t size);
MFBT_API void UnregisterJitCodeRegion(uint8_t* aStart, size_t size);
#endif // _M_AMD64
#endif // _M_AMD64 || _M_ARM64
#endif // mozilla_StackWalk_windows_h

Просмотреть файл

@ -31,7 +31,7 @@ void LoaderObserver::OnBeginDllLoad(void** aContext,
*aContext = utf8RequestedDllName.release();
}
#ifdef _M_AMD64
#if defined(_M_AMD64) || defined(_M_ARM64)
// Prevent the stack walker from suspending this thread when LdrLoadDll
// holds the RtlLookupFunctionEntry lock.
SuppressStackWalking();
@ -46,7 +46,7 @@ bool LoaderObserver::SubstituteForLSP(PCUNICODE_STRING aLSPLeafName,
void LoaderObserver::OnEndDllLoad(void* aContext, NTSTATUS aNtStatus,
ModuleLoadInfo&& aModuleLoadInfo) {
#ifdef _M_AMD64
#if defined(_M_AMD64) || defined(_M_ARM64)
DesuppressStackWalking();
#endif

Просмотреть файл

@ -481,7 +481,7 @@ static void PlatformInit(PSLockRef aLock) {}
PopulateRegsFromContext(regs, &context);
#endif
#if defined(GP_PLAT_amd64_windows)
#if defined(GP_PLAT_amd64_windows) || defined(GP_PLAT_arm64_windows)
// Use InitializeWin64ProfilerHooks from the base profiler.
@ -493,4 +493,4 @@ MFBT_API void InitializeWin64ProfilerHooks();
using mozilla::baseprofiler::InitializeWin64ProfilerHooks;
#endif // defined(GP_PLAT_amd64_windows)
#endif // defined(GP_PLAT_amd64_windows) || defined(GP_PLAT_arm64_windows)

Просмотреть файл

@ -5821,7 +5821,7 @@ static void locked_profiler_start(PSLockRef aLock, PowerOfTwo32 aCapacity,
baseprofiler::profiler_stop();
}
#if defined(GP_PLAT_amd64_windows)
#if defined(GP_PLAT_amd64_windows) || defined(GP_PLAT_arm64_windows)
InitializeWin64ProfilerHooks();
#endif