Commit edebee9e authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

Reduce BrokerServicesBase thread stack size

The default thread size for Chrome on 32-bit Windows is 1.5 MiB which is
overkill for the BrokerServicesBase thread. Address-space exhaustion can
be an issue for 32-bit Chrome, especially on 32-bit Windows, so this
change reduces the size to 0.5 MiB.

Bug: 981238, 1023804
Change-Id: I8cc90b506f3a14895f8e7a84fc0138c0e1d0775e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2422685
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: default avatarWill Harris <wfh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809550}
parent 2655d075
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "base/win/scoped_handle.h" #include "base/win/scoped_handle.h"
#include "base/win/scoped_process_information.h" #include "base/win/scoped_process_information.h"
#include "base/win/windows_version.h" #include "base/win/windows_version.h"
#include "build/build_config.h"
#include "sandbox/win/src/app_container_profile.h" #include "sandbox/win/src/app_container_profile.h"
#include "sandbox/win/src/process_mitigations.h" #include "sandbox/win/src/process_mitigations.h"
#include "sandbox/win/src/sandbox.h" #include "sandbox/win/src/sandbox.h"
...@@ -138,8 +139,17 @@ ResultCode BrokerServicesBase::Init() { ...@@ -138,8 +139,17 @@ ResultCode BrokerServicesBase::Init() {
no_targets_.Set(::CreateEventW(nullptr, true, false, nullptr)); no_targets_.Set(::CreateEventW(nullptr, true, false, nullptr));
job_thread_.Set(::CreateThread(nullptr, 0, // Default security and stack. #if defined(ARCH_CPU_32_BITS)
TargetEventsThread, this, 0, nullptr)); // Conserve address space in 32-bit Chrome. This thread uses a small and
// consistent amount and doesn't need the default of 1.5 MiB.
constexpr unsigned flags = STACK_SIZE_PARAM_IS_A_RESERVATION;
constexpr size_t stack_size = 128 * 1024;
#else
constexpr unsigned int flags = 0;
constexpr size_t stack_size = 0;
#endif
job_thread_.Set(::CreateThread(nullptr, stack_size, // Default security.
TargetEventsThread, this, flags, nullptr));
if (!job_thread_.IsValid()) if (!job_thread_.IsValid())
return SBOX_ERROR_CANNOT_INIT_BROKERSERVICES; return SBOX_ERROR_CANNOT_INIT_BROKERSERVICES;
......
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