diff options
-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); } |