Commit c6bf94fa authored by Paolo Severini's avatar Paolo Severini Committed by Commit Bot

Fix a race condition in win64_unwindinfo::RegisterNonABICompliantCodeRange

Function win64_unwindinfo::RegisterNonABICompliantCodeRange() calls
LoadNtdllUnwindingFunctions() to dynamically load from ntdll a couple of
functions that are not available on Windows 7. Unfortunately there is a
race condition in LoadNtdllUnwindingFunctions() that can cause a crash
when multiple isolates are initialized concurrently.
This can be fixed using base::CallOnce().

Bug: v8:9204
Change-Id: I5c57708ab5f16e9ef9f897efce1ccdf591e2f828
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1623592Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Paolo Severini <paolosev@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#61757}
parent aaecb433
......@@ -127,36 +127,33 @@ struct ExceptionHandlerRecord {
uint8_t exception_thunk[kMaxExceptionThunkSize];
};
namespace {
V8_DECLARE_ONCE(load_ntdll_unwinding_functions_once);
static decltype(
&::RtlAddGrowableFunctionTable) add_growable_function_table_func = nullptr;
static decltype(
&::RtlDeleteGrowableFunctionTable) delete_growable_function_table_func =
nullptr;
namespace {
void LoadNtdllUnwindingFunctions() {
static bool loaded = false;
if (loaded) {
return;
}
loaded = true;
// Load functions from the ntdll.dll module.
HMODULE ntdll_module =
LoadLibraryEx(L"ntdll.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
DCHECK_NOT_NULL(ntdll_module);
// This fails on Windows 7.
add_growable_function_table_func =
reinterpret_cast<decltype(&::RtlAddGrowableFunctionTable)>(
::GetProcAddress(ntdll_module, "RtlAddGrowableFunctionTable"));
DCHECK_IMPLIES(IsWindows8OrGreater(), add_growable_function_table_func);
delete_growable_function_table_func =
reinterpret_cast<decltype(&::RtlDeleteGrowableFunctionTable)>(
::GetProcAddress(ntdll_module, "RtlDeleteGrowableFunctionTable"));
DCHECK_IMPLIES(IsWindows8OrGreater(), delete_growable_function_table_func);
base::CallOnce(&load_ntdll_unwinding_functions_once, []() {
// Load functions from the ntdll.dll module.
HMODULE ntdll_module =
LoadLibraryEx(L"ntdll.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
DCHECK_NOT_NULL(ntdll_module);
// This fails on Windows 7.
add_growable_function_table_func =
reinterpret_cast<decltype(&::RtlAddGrowableFunctionTable)>(
::GetProcAddress(ntdll_module, "RtlAddGrowableFunctionTable"));
DCHECK_IMPLIES(IsWindows8OrGreater(), add_growable_function_table_func);
delete_growable_function_table_func =
reinterpret_cast<decltype(&::RtlDeleteGrowableFunctionTable)>(
::GetProcAddress(ntdll_module, "RtlDeleteGrowableFunctionTable"));
DCHECK_IMPLIES(IsWindows8OrGreater(), delete_growable_function_table_func);
});
}
bool AddGrowableFunctionTable(PVOID* DynamicTable,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment