diff options
author | Tim Jenßen <[email protected]> | 2025-01-30 17:15:06 +0100 |
---|---|---|
committer | Eike Ziller <[email protected]> | 2025-01-31 11:47:08 +0000 |
commit | a8a91607120eaeae5864569350e6736ad395e4b8 (patch) | |
tree | dd1f615a301f51652248c803665aa17b355d9684 | |
parent | c11c0208e950cbc568b0c2679e999e600e2c7e23 (diff) |
limit thread stack size to CRASHPAD_MAX_STACK_SIZE_KB20250131-based
default is 1024 KB
Sentry has a 100 MB limit with this we can reduce the dmp size.
The default crash butten test went from 50 MB to 10 MB.
Change-Id: Id497275f08a1b63f5fe82dc6a5ad48bb2e9565dc
Reviewed-by: Tim Jenssen <[email protected]>
-rw-r--r-- | snapshot/win/thread_snapshot_win.cc | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/snapshot/win/thread_snapshot_win.cc b/snapshot/win/thread_snapshot_win.cc index 576d8635..b395976b 100644 --- a/snapshot/win/thread_snapshot_win.cc +++ b/snapshot/win/thread_snapshot_win.cc @@ -60,6 +60,19 @@ ThreadSnapshotWin::ThreadSnapshotWin() ThreadSnapshotWin::~ThreadSnapshotWin() { } +WinVMSize GetMaxStackSize() { + wchar_t buffer[16] = {0}; + DWORD size = GetEnvironmentVariableW(L"CRASHPAD_MAX_STACK_SIZE_KB", buffer, ARRAYSIZE(buffer)); + if (size > 0 && size < ARRAYSIZE(buffer)) { + int kb = _wtoi(buffer); + if (kb > 0) { + return static_cast<WinVMSize>(kb) * 1024; + } + } + // default size + return static_cast<WinVMSize>(1024 * 1024); +} + bool ThreadSnapshotWin::Initialize( ProcessReaderWin* process_reader, const ProcessReaderWin::Thread& process_reader_thread, @@ -70,9 +83,12 @@ bool ThreadSnapshotWin::Initialize( if (process_reader->GetProcessInfo().LoggingRangeIsFullyReadable( CheckedRange<WinVMAddress, WinVMSize>(thread_.stack_region_address, thread_.stack_region_size))) { + static WinVMSize max_stack_size = GetMaxStackSize(); + WinVMSize limited_stack_size = + (thread_.stack_region_size < max_stack_size) ? thread_.stack_region_size : max_stack_size; stack_.Initialize(process_reader->Memory(), thread_.stack_region_address, - thread_.stack_region_size); + limited_stack_size); } else { stack_.Initialize(process_reader->Memory(), 0, 0); } |