diff options
author | sebmarchand@chromium.org <sebmarchand@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-10 23:17:57 +0000 |
---|---|---|
committer | sebmarchand@chromium.org <sebmarchand@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-10 23:17:57 +0000 |
commit | 4293c0de03800e9032ae2c6e738a6c23fec19f7c (patch) | |
tree | d0c2433198804463c47dd1798032344fc495c295 /base | |
parent | 5767ff47e0e0324d866b5c220458e1d9430c5373 (diff) | |
download | chromium_src-4293c0de03800e9032ae2c6e738a6c23fec19f7c.zip chromium_src-4293c0de03800e9032ae2c6e738a6c23fec19f7c.tar.gz chromium_src-4293c0de03800e9032ae2c6e738a6c23fec19f7c.tar.bz2 |
Patch for an inconsistency on the calls to Heap(Query/Set)Information.
This fix add more consistency in the way we call the Heap(Set/Query)Information functions.
In src/base/process_util_win.cc:EnableLowFragmentationHeap we use GetProcAddress to get a pointer to HeapSetInformation because this function is not exported in Windows 2000. If we want to be more consistent we should either accept the approach in this patch (use GetProcAddress to get a pointer to HeapQueryInformation) or directly call HeapSetInformation (as Chrome don't support Windows 2000).
FYI, this is the source of a bug in SyzyAsan because we hooks the calls to the kernel32:Heap* functions but we can't use our hook when the function is accessed via a function pointer yet. We can fix this but I think that it'll be more clean if were adopting the same logic in EnableLowFragmentationHeap and its unittest.
BUG=
Review URL: https://chromiumcodereview.appspot.com/11494006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172176 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/process_util_unittest.cc | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/base/process_util_unittest.cc b/base/process_util_unittest.cc index 6582073..4c1eff4 100644 --- a/base/process_util_unittest.cc +++ b/base/process_util_unittest.cc @@ -73,6 +73,12 @@ const int kExpectedKilledExitCode = 1; const int kExpectedStillRunningExitCode = 0; #endif +#if defined(OS_WIN) +// HeapQueryInformation function pointer. +typedef BOOL (WINAPI* HeapQueryFn) \ + (HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T, PSIZE_T); +#endif + // Sleeps until file filename is created. void WaitToDie(const char* filename) { FILE* fp; @@ -383,17 +389,29 @@ TEST_F(ProcessUtilTest, EnableLFH) { if (!no_debug_env || strcmp(no_debug_env, "1")) return; } + HMODULE kernel32 = GetModuleHandle(L"kernel32.dll"); + ASSERT_TRUE(kernel32 != NULL); + HeapQueryFn heap_query = reinterpret_cast<HeapQueryFn>(GetProcAddress( + kernel32, + "HeapQueryInformation")); + + // On Windows 2000, the function is not exported. This is not a reason to + // fail but we won't be able to retrieves information about the heap, so we + // should stop here. + if (heap_query == NULL) + return; + HANDLE heaps[1024] = { 0 }; unsigned number_heaps = GetProcessHeaps(1024, heaps); EXPECT_GT(number_heaps, 0u); for (unsigned i = 0; i < number_heaps; ++i) { ULONG flag = 0; SIZE_T length; - ASSERT_NE(0, HeapQueryInformation(heaps[i], - HeapCompatibilityInformation, - &flag, - sizeof(flag), - &length)); + ASSERT_NE(0, heap_query(heaps[i], + HeapCompatibilityInformation, + &flag, + sizeof(flag), + &length)); // If flag is 0, the heap is a standard heap that does not support // look-asides. If flag is 1, the heap supports look-asides. If flag is 2, // the heap is a low-fragmentation heap (LFH). Note that look-asides are not |