mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
windows: Configure stack size for executables (fixes issue #3250)
Change the default stack size to 8 MiB for 64-bit and 0.5 MiB for 32-bit. CEF's main thread needs at least a 1.5 MiB stack size in order to avoid stack overflow crashes. However, if this is set in the PE file then other threads get this size as well, leading to address-space exhaustion in 32-bit CEF. A new CefRunWinMainWithPreferredStackSize function uses fibers to switch the main thread to a 4 MiB stack (roughly the same effective size as the 64-bit build's 8 MiB stack) before running any other code. This change additionally moves the existing Windows-only functions CefSetOSModalLoop and CefEnableHighDPISupport from cef_app.h to cef_win.h.
This commit is contained in:
@@ -130,5 +130,22 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
|
||||
int nCmdShow) {
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
|
||||
#if defined(ARCH_CPU_32_BITS)
|
||||
// Run the main thread on 32-bit Windows using a fiber with the preferred 4MiB
|
||||
// stack size. This function must be called at the top of the executable entry
|
||||
// point function (`main()` or `wWinMain()`). It is used in combination with
|
||||
// the initial stack size of 0.5MiB configured via the `/STACK:0x80000` linker
|
||||
// flag on executable targets. This saves significant memory on threads (like
|
||||
// those in the Windows thread pool, and others) whose stack size can only be
|
||||
// controlled via the linker flag.
|
||||
int exit_code = CefRunWinMainWithPreferredStackSize(wWinMain, hInstance,
|
||||
lpCmdLine, nCmdShow);
|
||||
if (exit_code >= 0) {
|
||||
// The fiber has completed so return here.
|
||||
return exit_code;
|
||||
}
|
||||
#endif
|
||||
|
||||
return client::RunMain(hInstance, nCmdShow);
|
||||
}
|
||||
|
Reference in New Issue
Block a user