diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-09 17:12:32 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-09 17:12:32 +0000 |
commit | 2696c9d9aac84965fdbbeaafd5986ea8c49c624e (patch) | |
tree | 01ec4235a5fc63446f94e546c9374f796cc59fd3 /sandbox | |
parent | a25e90e8724d4c0dd942ec616295edbdc6cee892 (diff) | |
download | chromium_src-2696c9d9aac84965fdbbeaafd5986ea8c49c624e.zip chromium_src-2696c9d9aac84965fdbbeaafd5986ea8c49c624e.tar.gz chromium_src-2696c9d9aac84965fdbbeaafd5986ea8c49c624e.tar.bz2 |
Simplify ResolveNTFunctionPtr (temporary)
I want to test the theory that the issues we are observing here
are actually a race condition.
- The race condtion would be related with 2 operations that
are not thread safe:
1- check/creation of the map
2- search/insert on the map
I would like to air this CL on dev channel for a week and
observe the crash rate.
BUG=11789
Review URL: http://codereview.chromium.org/199052
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25741 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sandbox')
-rw-r--r-- | sandbox/src/win_utils.cc | 36 |
1 files changed, 3 insertions, 33 deletions
diff --git a/sandbox/src/win_utils.cc b/sandbox/src/win_utils.cc index ace9127..c20caf9 100644 --- a/sandbox/src/win_utils.cc +++ b/sandbox/src/win_utils.cc @@ -197,42 +197,12 @@ bool GetPathFromHandle(HANDLE handle, std::wstring* path) { }; // namespace sandbox -// The information is cached in a map. The map has to be global, so it's memory -// is leaked, and it's ok. +// TODO(cpu): Revert this change to use a map to speed up the function once +// this has been deployed in the dev channel for a week. See bug 11789. void ResolveNTFunctionPtr(const char* name, void* ptr) { - static std::map<std::string, FARPROC>* function_map = NULL; - if (!function_map) - function_map = new std::map<std::string, FARPROC>; - static HMODULE ntdll = ::GetModuleHandle(sandbox::kNtdllName); FARPROC* function_ptr = reinterpret_cast<FARPROC*>(ptr); - *function_ptr = (*function_map)[name]; - if (*function_ptr) - return; - *function_ptr = ::GetProcAddress(ntdll, name); - (*function_map)[name] = *function_ptr; - DCHECK(*function_ptr) << "Failed to resolve NTDLL function"; - - if (!*function_ptr) { - // If we return NULL, we are going to crash. Unfortunately, this happens. - // See bug 11789. - // Maybe our module handle is not valid anymore? - HMODULE ntdll2 = ::GetModuleHandle(sandbox::kNtdllName); - *function_ptr = ::GetProcAddress(ntdll2, name); - (*function_map)[name] = *function_ptr; - - // TODO(nsylvain): Remove this check after we are done troubleshooting. - CHECK(ntdll2) << "Fatal error: NTLL module is NULL"; - CHECK(*function_ptr) << "Fatal error: Failed to resolve NTDLL function"; - - // If we are here, it means that getting the new module handle worked. This - // is not really expected. We want to receive some reports from users, so - // we will crash anyway. - // TODO(nsylvain): Remove this check after we are done troubleshooting. - CHECK(ntdll) << "Fatal Error: NTDLL module was NULL."; - CHECK(ntdll == ntdll2) << "Fatal Error: NTDLL module has been moved."; - CHECK(false) << "Fatal Error: GetProcAddress Inconsistency"; - } + CHECK(*function_ptr) << "Failed to resolve NTDLL function"; } |