From 328de502ac3eb42922681172ddd72a5ca39a390c Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Mon, 26 Apr 2021 16:55:55 -0400 Subject: [PATCH] Windows: Disable iterator debugging for cef_sandbox builds (fixes issue #3109) Iterator debugging has been disabled by default (_HAS_ITERATOR_DEBUGGING=0) for CEF/Chromium builds using clang/LLVM since 2018. Inversely, it is enabled by default (_ITERATOR_DEBUG_LEVEL=2) for the MSVC Debug build configuration. In order to minimize configuration-related headaches for MSVC-based clients we have been building the Debug cef_sandbox.lib with iterator debugging enabled. Recently, we have identified a number of crashes that may be due to bugs in current clang/LLVM or MSVC versions but in any case can be resolved by disabling iterator debugging: - Crash when loading chrome://sandbox. - Crash if an application lists libraries that utilize iterators after cef_sandbox.lib in the linker order. To resolve these crashes we will now disable iterator debugging by default for the cef_sandbox.lib builds. Client applications that link cef_sandbox.lib will now also need to build with iterator debugging disabled by setting _HAS_ITERATOR_DEBUGGING=0 or _ITERATOR_DEBUG_LEVEL=0 in their project configuration (this will be done for you if you use cef_variables.cmake from the binary distribution). In addition to the crash fixes mentioned above, this change also: - Reduces the size of the Debug cef_sandbox.lib by ~10MB. - May result in faster Debug executables (see https://crbug.com/539996). --- cmake/cef_variables.cmake.in | 3 +++ tools/gn_args.py | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cmake/cef_variables.cmake.in b/cmake/cef_variables.cmake.in index 8e7c18544..2dced947c 100644 --- a/cmake/cef_variables.cmake.in +++ b/cmake/cef_variables.cmake.in @@ -491,6 +491,9 @@ if(OS_WINDOWS) PSAPI_VERSION=1 # Required by cef_sandbox.lib CEF_USE_SANDBOX # Used by apps to test if the sandbox is enabled ) + list(APPEND CEF_COMPILER_DEFINES_DEBUG + _HAS_ITERATOR_DEBUGGING=0 # Disable iterator debugging + ) # Libraries required by cef_sandbox.lib. set(CEF_SANDBOX_STANDARD_LIBS diff --git a/tools/gn_args.py b/tools/gn_args.py index 7d07f4569..2b277cdf5 100644 --- a/tools/gn_args.py +++ b/tools/gn_args.py @@ -480,10 +480,6 @@ def GetConfigArgsSandbox(platform, args, is_debug, cpu): 'is_cef_sandbox_build': True, } - if is_debug: - # Enable iterator debugging (_ITERATOR_DEBUG_LEVEL=2). - add_args['enable_iterator_debugging'] = True - if platform == 'windows': # Avoid Debug build linker errors caused by custom libc++. add_args['use_custom_libcxx'] = False