summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjschuh@chromium.org <jschuh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-27 18:46:57 +0000
committerjschuh@chromium.org <jschuh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-27 18:46:57 +0000
commitb9c587d5a7e5d0a6c669b4fd2fd6d09985b26a2f (patch)
treeb1d4ec0447a2d7f7d8a20668cbdff155c645c40d
parentaea9451b78849d51b87ef8799d3f8cb63ea4cb5d (diff)
downloadchromium_src-b9c587d5a7e5d0a6c669b4fd2fd6d09985b26a2f.zip
chromium_src-b9c587d5a7e5d0a6c669b4fd2fd6d09985b26a2f.tar.gz
chromium_src-b9c587d5a7e5d0a6c669b4fd2fd6d09985b26a2f.tar.bz2
Modifying ResolveNTFunctionPtr in an attempt to eliminate crashes on random unresolved functions.
BUG=11789 TEST=None. Review URL: http://codereview.chromium.org/7276004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90614 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--sandbox/src/win_utils.cc25
1 files changed, 18 insertions, 7 deletions
diff --git a/sandbox/src/win_utils.cc b/sandbox/src/win_utils.cc
index 5a846e0..8a43d97 100644
--- a/sandbox/src/win_utils.cc
+++ b/sandbox/src/win_utils.cc
@@ -298,15 +298,26 @@ bool WriteProtectedChildMemory(HANDLE child_process, void* address,
}; // namespace sandbox
-// TODO(cpu): This is not the final code we want here but we are yet
-// to understand what is going on. See bug 11789.
+// TODO(jschuh): http://crbug.com/11789
+// I'm guessing we have a race where some "security" software is messing
+// with ntdll/imports underneath us. So, we retry a few times, and in the
+// worst case we sleep briefly before a few more attempts. (Normally sleeping
+// would be very bad, but it's better than crashing in this case.)
void ResolveNTFunctionPtr(const char* name, void* ptr) {
- HMODULE ntdll = ::GetModuleHandle(sandbox::kNtdllName);
+ const int max_tries = 5;
+ const int sleep_threshold = 2;
+
+ static HMODULE ntdll = ::GetModuleHandle(sandbox::kNtdllName);
+
FARPROC* function_ptr = reinterpret_cast<FARPROC*>(ptr);
*function_ptr = ::GetProcAddress(ntdll, name);
- if (*function_ptr)
- return;
- // We have data that re-trying helps.
- *function_ptr = ::GetProcAddress(ntdll, name);
+
+ for (int tries = 1; !(*function_ptr) && tries < max_tries; ++tries) {
+ if (tries >= sleep_threshold)
+ ::Sleep(1);
+ ntdll = ::GetModuleHandle(sandbox::kNtdllName);
+ *function_ptr = ::GetProcAddress(ntdll, name);
+ }
+
CHECK(*function_ptr);
}