diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-05-20 18:53:40 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-06-10 09:05:17 +0200 |
commit | 68dd6cc92b81cc2253cdfcdc53823ad6527d2e05 (patch) | |
tree | 68f5b226b06e50f0a29ead8cc5ec337a3d51865a | |
parent | c1887974ccbf00f4c5a4950480eb53cf75c153a0 (diff) | |
download | php-git-68dd6cc92b81cc2253cdfcdc53823ad6527d2e05.tar.gz |
Control VCRT leak reporting via environment variable in debug builds
Formerly, this had to be enabled by passing the configuration flag
`--enable-crt-debug`; now it can be enabled by setting the environment
variable `PHP_WIN32_DEBUG_HEAP`. The advantage is that it is no longer
necessary to do separate builds, at the cost of a very minor
performance penalty during process startup.
-rw-r--r-- | UPGRADING.INTERNALS | 5 | ||||
-rw-r--r-- | Zend/zend_portability.h | 2 | ||||
-rw-r--r-- | ext/libxml/config.w32 | 3 | ||||
-rw-r--r-- | sapi/cli/config.w32 | 4 | ||||
-rw-r--r-- | sapi/cli/php_cli.c | 29 | ||||
-rw-r--r-- | win32/build/confutils.js | 2 |
6 files changed, 23 insertions, 22 deletions
diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index def57d94b9..58fec72abf 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -135,6 +135,11 @@ PHP 8.0 INTERNALS UPGRADE NOTES c. Windows build system changes + - The configuration option --enable-crt-debug has been removed. The VC + debug heap can now be enabled for debug builds by setting the environment + variable PHP_WIN32_DEBUG_HEAP to a non-negative number before PHP process + startup. + ======================== 3. Module changes ======================== diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index 023fcd0510..73ac3b4e41 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -613,7 +613,7 @@ extern "C++" { # define ZEND_PREFER_RELOAD #endif -#if defined(ZEND_WIN32) && defined(_DEBUG) && defined(PHP_WIN32_DEBUG_HEAP) +#if defined(ZEND_WIN32) && defined(_DEBUG) # define ZEND_IGNORE_LEAKS_BEGIN() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) & ~_CRTDBG_ALLOC_MEM_DF) # define ZEND_IGNORE_LEAKS_END() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_ALLOC_MEM_DF) #else diff --git a/ext/libxml/config.w32 b/ext/libxml/config.w32 index dd91c4b893..b11c57bc44 100644 --- a/ext/libxml/config.w32 +++ b/ext/libxml/config.w32 @@ -16,9 +16,6 @@ if (PHP_LIBXML == "yes") { ADD_DEF_FILE("ext\\libxml\\php_libxml2.def"); } PHP_INSTALL_HEADERS("ext/libxml/", "php_libxml.h"); - if (PHP_CRT_DEBUG == "yes") { - ADD_FLAG("CFLAGS_LIBXML", "/D PHP_WIN32_DEBUG_HEAP"); - } } else { WARNING("libxml support can't be enabled, iconv or libxml are missing") PHP_LIBXML = "no" diff --git a/sapi/cli/config.w32 b/sapi/cli/config.w32 index 26c53f7808..28bb2fd4c6 100644 --- a/sapi/cli/config.w32 +++ b/sapi/cli/config.w32 @@ -1,16 +1,12 @@ // vim:ft=javascript ARG_ENABLE('cli', 'Build CLI version of PHP', 'yes'); -ARG_ENABLE('crt-debug', 'Enable CRT memory dumps for debugging sent to STDERR', 'no'); ARG_ENABLE('cli-win32', 'Build console-less CLI version of PHP', 'no'); if (PHP_CLI == "yes") { SAPI('cli', 'php_cli.c php_http_parser.c php_cli_server.c php_cli_process_title.c ps_title.c', 'php.exe', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1'); ADD_FLAG("LIBS_CLI", "ws2_32.lib"); ADD_FLAG("LIBS_CLI", "shell32.lib"); - if (PHP_CRT_DEBUG == "yes") { - ADD_FLAG("CFLAGS_CLI", "/D PHP_WIN32_DEBUG_HEAP"); - } ADD_FLAG("LDFLAGS_CLI", "/stack:67108864"); if (CHECK_LIB("edit_a.lib;edit.lib", "cli", PHP_CLI) && diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index a9069c6191..dfda90fb8e 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -1184,20 +1184,23 @@ int main(int argc, char *argv[]) cli_sapi_module.additional_functions = additional_functions; -#if defined(PHP_WIN32) && defined(_DEBUG) && defined(PHP_WIN32_DEBUG_HEAP) +#if defined(PHP_WIN32) && defined(_DEBUG) { - int tmp_flag; - _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); - _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); - _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); - _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); - _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE); - _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); - tmp_flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); - tmp_flag |= _CRTDBG_DELAY_FREE_MEM_DF; - tmp_flag |= _CRTDBG_LEAK_CHECK_DF; - - _CrtSetDbgFlag(tmp_flag); + char *tmp = getenv("PHP_WIN32_DEBUG_HEAP"); + if (tmp && zend_atoi(tmp, 0)) { + int tmp_flag; + _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); + _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); + _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); + tmp_flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); + tmp_flag |= _CRTDBG_DELAY_FREE_MEM_DF; + tmp_flag |= _CRTDBG_LEAK_CHECK_DF; + + _CrtSetDbgFlag(tmp_flag); + } } #endif diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 9d2d578516..5d6ba3baac 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -437,7 +437,7 @@ can be built that way. \ } var snapshot_build_exclusions = new Array( - 'debug', 'crt-debug', 'lzf-better-compression', + 'debug', 'lzf-better-compression', 'php-build', 'snapshot-template', 'ereg', 'pcre-regex', 'fastcgi', 'force-cgi-redirect', 'path-info-check', 'zts', 'ipv6', 'memory-limit', |