com php-src: Report mem leaks to stderr if no Win debugger is present: main/main.c
| From: | Christoph Michael Becker | Date: | Sat, 08 Sep 2018 11:57:01 +0000 |
| Subject: | com php-src: Report mem leaks to stderr if no Win debugger is present: main/main.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-103022@lists.php.net to get a copy of this message | ||
Commit: 3145d6c6b9286c13bc84496d3f3d9853a030136a
Author: Christoph M. Becker <cmbecker69@gmx.de> Sat, 8 Sep 2018 13:57:01 +0200
Parents: 98b01a14e3f29a058952563cd90785227dcfb3f6
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3145d6c6b9286c13bc84496d3f3d9853a030136a
Log:
Report mem leaks to stderr if no Win debugger is present
Formerly, we sent output regarding memory leaks always to the debugger
on Windows, but this appears to be not useful especially for the PHPTs,
which usually are not run under a debugger, and so important info will
not be available there.
Changed paths:
M main/main.c
Diff:
diff --git a/main/main.c b/main/main.c
index e4ae28d..c9c05de 100644
--- a/main/main.c
+++ b/main/main.c
@@ -1681,7 +1681,11 @@ static ZEND_COLD void php_message_handler_for_zend(zend_long message, const
void
snprintf(memory_leak_buf, 512, "Last leak repeated %lu time%s\n", leak_count,
(leak_count>1?"s":""));
}
# if defined(PHP_WIN32)
- OutputDebugString(memory_leak_buf);
+ if (IsDebuggerPresent()) {
+ OutputDebugString(memory_leak_buf);
+ } else {
+ fprintf(stderr, "%s", memory_leak_buf);
+ }
# else
fprintf(stderr, "%s", memory_leak_buf);
# endif
@@ -1695,7 +1699,11 @@ static ZEND_COLD void php_message_handler_for_zend(zend_long message, const
void
snprintf(memory_leak_buf, 512, "=== Total %d memory leaks detected ===\n",
*((uint32_t *) data));
# if defined(PHP_WIN32)
- OutputDebugString(memory_leak_buf);
+ if (IsDebuggerPresent()) {
+ OutputDebugString(memory_leak_buf);
+ } else {
+ fprintf(stderr, "%s", memory_leak_buf);
+ }
# else
fprintf(stderr, "%s", memory_leak_buf);
# endif
@@ -1718,7 +1726,11 @@ static ZEND_COLD void php_message_handler_for_zend(zend_long message, const
void
snprintf(memory_leak_buf, sizeof(memory_leak_buf), "[null] Script:
'%s'\n", SAFE_FILENAME(SG(request_info).path_translated));
}
# if defined(PHP_WIN32)
- OutputDebugString(memory_leak_buf);
+ if (IsDebuggerPresent()) {
+ OutputDebugString(memory_leak_buf);
+ } else {
+ fprintf(stderr, "%s", memory_leak_buf);
+ }
# else
fprintf(stderr, "%s", memory_leak_buf);
# endif