cvs: php-bugs-web / bugs-generating-backtrace.php

From: Date: Sun, 16 Dec 2001 15:50:27 +0000
Subject: cvs: php-bugs-web / bugs-generating-backtrace.php
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-7872@lists.php.net to get a copy of this message
sniper Sun Dec 16 10:50:27 2001 EDT Modified files: /php-bugs-web bugs-generating-backtrace.php Log: Applied some additions by Yasuo Ohgaki. Index: php-bugs-web/bugs-generating-backtrace.php diff -u php-bugs-web/bugs-generating-backtrace.php:1.1 php-bugs-web/bugs-generating-backtrace.php:1.2 --- php-bugs-web/bugs-generating-backtrace.php:1.1 Thu Sep 20 20:59:45 2001 +++ php-bugs-web/bugs-generating-backtrace.php Sun Dec 16 10:50:27 2001 @@ -63,9 +63,10 @@ <li>(gdb) run -X</li> </ul> </li> -<li>Then use your web browser and access your server to force the crash. -You should see a gdb prompt appear and some message indicating that -there was a crash. At this gdb prompt, type: +<li> + Then use your web browser and access your server to force the crash. + You should see a gdb prompt appear and some message indicating that + there was a crash. At this gdb prompt, type: <ul> <li><code>(gdb) bt</code></li> </ul> @@ -75,5 +76,65 @@ <p>This should generate a backtrace, that you should submit in the bug report, along with any other details you can give us about your setup, and offending script.</p> + +<h3>Locating which function call caused segfault:</h3> + +<p>You can locate function call that caused segfault easily with gdb. +First you need core file or generate segfault under gdb as desccribed +above.</p> + +<p>In PHP, function is executed by internal function called +<b><code>execute()</code></b> and has its own stack. Each line +generated by <b><code>bt</code></b> command represents function call +stack. Typically, you will see several +<b><code>execute()</code></b> when you issue +<b><code>bt</code></b>. You are interested in the last +<b><code>execute()</code></b> stack. (i.e. smallest frame +number) You can move stack currently working with +<b><code>up</code></b>, <code>down</code> or +<b><code>frame</code></b>command. Below is an example gdb session and +you can do the same for your segfault. </p> + +<ul> + <li>Sample gdb session</li> + <pre><code> +(gdb) bt +#0 0x080ca21b in _efree (ptr=0xbfffdb9b) at zend_alloc.c:240 +#1 0x080d691a in _zval_dtor (zvalue=0x8186b94) at zend_variables.c:44 +#2 0x080cfab3 in _zval_ptr_dtor (zval_ptr=0xbfffdbfc) at zend_execute_API.c:274 +#3 0x080f1cc4 in execute (op_array=0x816c670) at ./zend_execute.c:1605 +#4 0x080f1e06 in execute (op_array=0x816c530) at ./zend_execute.c:1638 +#5 0x080f1e06 in execute (op_array=0x816c278) at ./zend_execute.c:1638 +#6 0x080f1e06 in execute (op_array=0x8166eec) at ./zend_execute.c:1638 +#7 0x080d7b93 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at zend.c:810 +#8 0x0805ea75 in php_execute_script (primary_file=0xbffff650) at main.c:1310 +#9 0x0805cdb3 in main (argc=2, argv=0xbffff6fc) at cgi_main.c:753 +#10 0x400c91be in __libc_start_main (main=0x805c580 <main>, argc=2, ubp_av=0xbffff6fc, + init=0x805b080 <_init>, fini=0x80f67b4 <_fini>, rtld_fini=0x4000ddd0 <_dl_fini>, + stack_end=0xbffff6ec) at ../sysdeps/generic/libc-start.c:129 +(gdb) frame 3 +#3 0x080f1cc4 in execute (op_array=0x816c670) at ./zend_execute.c:1605 +(gdb) print (char *)(executor_globals.function_state_ptr->function)->common.function_name +$14 = 0x80fa6fa "pg_result_error" +(gdb) print (char *)executor_globals.active_op_array->function_name +$15 = 0x816cfc4 "result_error" +(gdb) print (char *)executor_globals.active_op_array->filename +$16 = 0x816afbc "/home/yohgaki/cvs/php/DEV/segfault.php" +(gdb) + </code></pre> +</ul> + +<p>In this session, frame 3 is the last <b><code>execute()</code></b> +call. <b><code>frame 3</code></b> command move current working stack +to the frame.<br /> +<b><code>print (char *)(executor_globals.function_state_ptr->function)->common.function_name</code></b><br /> +prints function name. In sample gdb session, pg_result_error() call +is causing the segfault. You can print any internal data as you want +if you know the internal data structure. Please do not ask how to use gdb +or about the internal data structure. Refer to gdb manual for gdb usage +and PHP source for the internal data structure.</p> + +<p>You may not see <b><code>execute</code></b> if the segfault happens +without calling any functions.</p> <?php commonFooter(); ?>

« previous php.mirrors (#7872) next »