diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-24 19:22:36 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-24 19:22:36 +0000 |
commit | 10128a6d664a60f0808f1bd4ffd5b187b3fdb151 (patch) | |
tree | 1b5f34813fefd88ec40d1f0a95c86456d1d9adc2 /base | |
parent | dc033989801c1233e5488bbcfcd878dcb4fc3c1c (diff) | |
download | chromium_src-10128a6d664a60f0808f1bd4ffd5b187b3fdb151.zip chromium_src-10128a6d664a60f0808f1bd4ffd5b187b3fdb151.tar.gz chromium_src-10128a6d664a60f0808f1bd4ffd5b187b3fdb151.tar.bz2 |
Avoid spawning a thread while enabling the OOM killer on the Mac.
BUG=53200
TEST=n/a
Review URL: http://codereview.chromium.org/3162034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57218 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/process_util_mac.mm | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/base/process_util_mac.mm b/base/process_util_mac.mm index 0bdc134..2ea59a0 100644 --- a/base/process_util_mac.mm +++ b/base/process_util_mac.mm @@ -17,6 +17,7 @@ #include <sys/mman.h> #include <sys/sysctl.h> #include <sys/types.h> +#include <sys/utsname.h> #include <sys/wait.h> #include <new> @@ -613,10 +614,17 @@ void EnableTerminationOnOutOfMemory() { g_oom_killer_enabled = true; - int32 os_major; - int32 os_minor; - int32 os_bugfix; - SysInfo::OperatingSystemVersionNumbers(&os_major, &os_minor, &os_bugfix); + // Not SysInfo::OperatingSystemVersionNumbers as that calls through to Gestalt + // which ends up (on > 10.6) spawning threads. + struct utsname machine_info; + if (uname(&machine_info)) { + return; + } + + // The string machine_info.release is the xnu/Darwin version number, "9.xxx" + // on Mac OS X 10.5, and "10.xxx" on Mac OS X 10.6. See + // http://en.wikipedia.org/wiki/Darwin_(operating_system) . + long darwin_version = strtol(machine_info.release, NULL, 10); // === C malloc/calloc/valloc/realloc/posix_memalign === @@ -635,8 +643,7 @@ void EnableTerminationOnOutOfMemory() { !g_old_memalign_purgeable) << "Old allocators unexpectedly non-null"; // See http://trac.webkit.org/changeset/53362/trunk/WebKitTools/DumpRenderTree/mac - bool zone_allocators_protected = - ((os_major == 10 && os_minor > 6) || os_major > 10); + bool zone_allocators_protected = darwin_version > 10; ChromeMallocZone* default_zone = reinterpret_cast<ChromeMallocZone*>(malloc_default_zone()); @@ -752,7 +759,7 @@ void EnableTerminationOnOutOfMemory() { << "Old allocators unexpectedly non-null"; bool cf_allocator_internals_known = - (os_major == 10 && (os_minor == 5 || os_minor == 6)); + darwin_version == 9 || darwin_version == 10; if (cf_allocator_internals_known) { ChromeCFAllocatorRef allocator = const_cast<ChromeCFAllocatorRef>( |