cvs: php-bugs-web / bugs-getting-valgrind-log.php how-to-report.php
| From: | Antony Dovgal | Date: | Tue, 27 Nov 2007 09:02:45 +0000 |
| Subject: | cvs: php-bugs-web / bugs-getting-valgrind-log.php how-to-report.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-596@lists.php.net to get a copy of this message | ||
tony2001 Tue Nov 27 09:02:45 2007 UTC
Added files:
/php-bugs-web bugs-getting-valgrind-log.php
Modified files:
/php-bugs-web how-to-report.php
Log:
add valgrind log instructions
http://cvs.php.net/viewvc.cgi/php-bugs-web/how-to-report.php?r1=1.12&r2=1.13&diff_format=u
Index: php-bugs-web/how-to-report.php
diff -u php-bugs-web/how-to-report.php:1.12 php-bugs-web/how-to-report.php:1.13
--- php-bugs-web/how-to-report.php:1.12 Tue May 16 07:17:28 2006
+++ php-bugs-web/how-to-report.php Tue Nov 27 09:02:45 2007
@@ -98,6 +98,10 @@
can be found <a href="bugs-generating-backtrace.php">here for *NIX
users</a> and
<a href="bugs-generating-backtrace-win32.php">here for Windows users</a>.
</li>
+ <li>
+ <a href="http://valgrind.org">Valgrind</a> log can be also
very useful.
+ See <a href="bugs-getting-valgrind-log.php">instructions how to generate
it</a>.
+ </li>
</ul>
<h2>Use English.</h2>
http://cvs.php.net/viewvc.cgi/php-bugs-web/bugs-getting-valgrind-log.php?view=markup&rev=1.1
Index: php-bugs-web/bugs-getting-valgrind-log.php
+++ php-bugs-web/bugs-getting-valgrind-log.php
<?php
require_once 'prepend.inc';
commonHeader("Generating a valgrind log");
?>
<h1>Generating a valgrind log</h1>
<h3>Important!</h3>
To get a meaningful log you must have
PHP configured with <code>--enable-debug</code>
and disable Zend memory manager.
<h3>Disabling Zend MM</h3>
<p>
Zend Engine uses its own routines to optimize memory management,
but because of this valgrind cannot see most of the memory issues.
You must disable Zend memory manager before running PHP with valgrind.
In order to do this you need to set USE_ZEND_ALLOC environment
variable to 0.
</p>
<p>
Use
<pre><code>export USE_ZEND_ALLOC=0</code></pre> or
<pre><code>setenv USE_ZEND_ALLOC 0</code></pre> (the syntax depends on
what your shell supports).
</p>
<p>
This works since PHP 5.2 (with debug builds only),
in older versions you had to reconfigure PHP with
<code>--disable-zend-memory-manager</code> option.
</p>
<h3>Running PHP CLI or PHP CGI through valgrind</h3>
<p>
To generate the valgrind log using PHP CLI/CGI,
you need to execute the following command:
</p>
<pre>
<code>
valgrind --tool=memcheck --num-callers=30 --log-file-exactly=php.log /path/to/php-cli script.php
</code>
</pre>
<p>
This should put the log into php.log file in the current working directory.
</p>
<h3>Running PHP Apache module through valgrind</h3>
<p>
If you compiled PHP and Apache statically, make sure the Apache binary
is not stripped after <code>make install</code>, otherwise you lose
the required debug info. To check it, run <code>file /path/to/httpd</code>,
it should output something like this (notice "not stripped"):
</p>
<pre>
<code>
# file /usr/local/apache2/bin/httpd
/usr/local/apache2/bin/httpd: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), for GNU/Linux
2.6.4, dynamically linked (uses shared libs), not stripped
</code>
</pre>
<p>
To generate the valgrind log using PHP as Apache module,
you need to run the Apache itself under valgrind:
</p>
<pre>
<code>
valgrind --tool=memcheck --num-callers=30 --log-file-exactly=apache.log /usr/local/apache/bin/httpd
-X
</code>
</pre>
<p>
This should put all the memory errors into into apache.log file.
</p>
<?php commonFooter(); ?>