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:
@@ -9,7 +9,7 @@
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=bb6f61b0d69253de7bcc5506fd04562e46fa797c$
|
||||
// $hash=b5dc1bb07ea5cbf057bf40491fdcdddeb58dfa57$
|
||||
//
|
||||
|
||||
#include <dlfcn.h>
|
||||
@@ -95,8 +95,6 @@ struct libcef_pointers {
|
||||
decltype(&cef_do_message_loop_work) cef_do_message_loop_work;
|
||||
decltype(&cef_run_message_loop) cef_run_message_loop;
|
||||
decltype(&cef_quit_message_loop) cef_quit_message_loop;
|
||||
decltype(&cef_set_osmodal_loop) cef_set_osmodal_loop;
|
||||
decltype(&cef_enable_highdpi_support) cef_enable_highdpi_support;
|
||||
decltype(&cef_crash_reporting_enabled) cef_crash_reporting_enabled;
|
||||
decltype(&cef_set_crash_key_value) cef_set_crash_key_value;
|
||||
decltype(&cef_create_directory) cef_create_directory;
|
||||
@@ -336,8 +334,6 @@ int libcef_init_pointers(const char* path) {
|
||||
INIT_ENTRY(cef_do_message_loop_work);
|
||||
INIT_ENTRY(cef_run_message_loop);
|
||||
INIT_ENTRY(cef_quit_message_loop);
|
||||
INIT_ENTRY(cef_set_osmodal_loop);
|
||||
INIT_ENTRY(cef_enable_highdpi_support);
|
||||
INIT_ENTRY(cef_crash_reporting_enabled);
|
||||
INIT_ENTRY(cef_set_crash_key_value);
|
||||
INIT_ENTRY(cef_create_directory);
|
||||
@@ -599,14 +595,6 @@ NO_SANITIZE("cfi-icall") void cef_quit_message_loop() {
|
||||
g_libcef_pointers.cef_quit_message_loop();
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall") void cef_set_osmodal_loop(int osModalLoop) {
|
||||
g_libcef_pointers.cef_set_osmodal_loop(osModalLoop);
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall") void cef_enable_highdpi_support() {
|
||||
g_libcef_pointers.cef_enable_highdpi_support();
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall") int cef_crash_reporting_enabled() {
|
||||
return g_libcef_pointers.cef_crash_reporting_enabled();
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=f1ec7f73b35927e943a058141d73d449dd31e43c$
|
||||
// $hash=24d0396cbcb6e2af587c1126c899277d4ac0b4d2$
|
||||
//
|
||||
|
||||
#include "include/capi/cef_app_capi.h"
|
||||
@@ -138,20 +138,6 @@ NO_SANITIZE("cfi-icall") CEF_GLOBAL void CefQuitMessageLoop() {
|
||||
cef_quit_message_loop();
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall") CEF_GLOBAL void CefSetOSModalLoop(bool osModalLoop) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_set_osmodal_loop(osModalLoop);
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall") CEF_GLOBAL void CefEnableHighDPISupport() {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_enable_highdpi_support();
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall") CEF_GLOBAL bool CefCrashReportingEnabled() {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
|
@@ -1,3 +1,62 @@
|
||||
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
||||
// Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "include/base/cef_build.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
|
||||
#include "include/base/cef_compiler_specific.h"
|
||||
#include "include/base/cef_logging.h"
|
||||
#include "include/cef_api_hash.h"
|
||||
#include "include/internal/cef_win.h"
|
||||
|
||||
#if defined(ARCH_CPU_32_BITS)
|
||||
NO_SANITIZE("cfi-icall")
|
||||
int CefRunWinMainWithPreferredStackSize(wWinMainPtr wWinMain,
|
||||
HINSTANCE hInstance,
|
||||
LPWSTR lpCmdLine,
|
||||
int nCmdShow) {
|
||||
CHECK(wWinMain && hInstance);
|
||||
|
||||
const char* api_hash = cef_api_hash(0);
|
||||
if (strcmp(api_hash, CEF_API_HASH_PLATFORM)) {
|
||||
// The libcef API hash does not match the current header API hash.
|
||||
NOTREACHED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return cef_run_winmain_with_preferred_stack_size(wWinMain, hInstance,
|
||||
lpCmdLine, nCmdShow);
|
||||
}
|
||||
|
||||
int CefRunMainWithPreferredStackSize(mainPtr main, int argc, char* argv[]) {
|
||||
CHECK(main);
|
||||
|
||||
const char* api_hash = cef_api_hash(0);
|
||||
if (strcmp(api_hash, CEF_API_HASH_PLATFORM)) {
|
||||
// The libcef API hash does not match the current header API hash.
|
||||
NOTREACHED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return cef_run_main_with_preferred_stack_size(main, argc, argv);
|
||||
}
|
||||
#endif // defined(ARCH_CPU_32_BITS)
|
||||
|
||||
NO_SANITIZE("cfi-icall") void CefEnableHighDPISupport() {
|
||||
const char* api_hash = cef_api_hash(0);
|
||||
if (strcmp(api_hash, CEF_API_HASH_PLATFORM)) {
|
||||
// The libcef API hash does not match the current header API hash.
|
||||
NOTREACHED();
|
||||
return;
|
||||
}
|
||||
|
||||
cef_enable_highdpi_support();
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall") void CefSetOSModalLoop(bool osModalLoop) {
|
||||
cef_set_osmodal_loop(osModalLoop);
|
||||
}
|
||||
|
||||
#endif // defined(OS_WIN)
|
||||
|
Reference in New Issue
Block a user