php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56433 PHP segfaults when starting profiling
Submitted: 2005-06-29 09:09 UTC Modified: 2015-02-26 07:33 UTC
Votes:3
Avg. Score:1.7 ± 0.9
Reproduced:0 of 1 (0.0%)
From: wim dot heirman at elis dot ugent dot be Assigned:
Status: Suspended Package: apd (PECL)
PHP Version: 5.0.3 OS: Fedora Core 4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
22 + 50 = ?
Subscribe to this entry?

 
 [2005-06-29 09:09 UTC] wim dot heirman at elis dot ugent dot be
Description:
------------
When executing a simple script containing just "<?php apd_set_pprof_trace(); ?>", PHP/APD segfaults. GDB output:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1209042048 (LWP 1308)]
0x08168f15 in zend_get_executed_lineno ()
(gdb) bt
#0  0x08168f15 in zend_get_executed_lineno ()
#1  0x001139ad in log_time () at /tmp/tmp2zspMp/apd-1.0.1/php_apd.c:424
#2  0x00113a38 in trace_function_exit (fname=0x8ba4f5c "main") at /tmp/tmp2zspMp/apd-1.0.1/php_apd.c:399
#3  0x00113c37 in apd_execute (op_array=0x8ba8cec) at /tmp/tmp2zspMp/apd-1.0.1/php_apd.c:519
#4  0x08173aba in zend_execute_scripts ()
#5  0x0813e7e0 in php_execute_script ()
#6  0x081a859e in main ()


In contrast to bug #3383, `PHP -v` works OK here and gives:

PHP 5.0.4 (cli) (built: May  9 2005 11:21:11)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.4-dev, Copyright (c) 1998-2004 Zend Technologies
    with Advanced PHP Debugger (APD) v0.9, , by George Schlossnagle

I'm using APD-1.0.1 and PHP-5.0.4.


Reproduce code:
---------------
echo "<?php apd_set_pprof_trace(); ?>"|php

Expected result:
----------------
Segmentation fault


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-27 05:13 UTC] thelinuxtech at gmail dot com
Same thing here.

FC4
PHP compiled from php-5.0.4-10.3.src.rpm

Happens with 'pear install apd' install and with manual install from apd-1.0.1.tgz tarball.

Easily reproducible: just add 'apd_set_pprof_trace();' in any otherwise working php script :).
 [2005-10-24 11:48 UTC] joustin at post dot pl
Same here... same versions, all from RPMs. Segfaults every time when trying to init profiling :(
 [2005-10-26 13:27 UTC] liquidx at liquid-x dot net
Same problem here, with PHP 4 / APD 0.9.2 from source.
 [2005-11-29 05:51 UTC] blade106 at free dot fr
Same problem with all flavours of PHP 5 :
- PHP 5.1 stable w/ APD-1.0.1
- PHP 5.0.4 w/ APD-1.0.1
- PHP 5.0.4 w/ APD-1.0

But there's something special : the debug file (pprof.XXXXX.Y) is in the apd dir !

So the Segmentation fault occurs at the end of the PHP script. Can this info help you ?
Also the Segmentation fault appears in 80% of page loads, not on every load.
 [2005-11-29 05:53 UTC] blade106 at free dot fr
Sorry, I forgot to mention : I'm on a Debian box, Apache 2.0.55, no eaccelerator/APC installed.
 [2005-11-29 07:57 UTC] yvan dot taviaud_pecl at m4am dot net
Sorry for this third post (still "blade106"), but when the apd.so is activated in php.ini (using zend_extension), even if the apd_set_pprof_trace() call is not present, some scripts finish in a Segmentation fault...

Is there a mail tracking for this bug system ? Because my email seems to be cut (domain : free.fr, it's a French ISP)... I'll try another email to verify this.
 [2006-03-05 19:14 UTC] devnull at munkyboy dot com
I had the same exact problem on OS X 10.4.5. I'm using Apache 1.3.33, PHP 4.4.2, and APD 0.9.2. my crash log looks like this:

Thread 0 Crashed:
0   httpd       0x0002b2d4 zend_get_executed_lineno + 44
1   apd.so      0x002d1a10 log_time + 184 (php_apd.c:424)
2   apd.so      0x002d1aa8 trace_function_exit + 64 (php_apd.c:400)
...

I was able to fix the problem by using GCC 3.3 to compile APD. I initally built my Apache, PHP, and APD using GCC 4.0.1. When I switched to GCC 3.3 for APD building, no more SEGFAULTS!  :)
 [2006-07-19 00:38 UTC] screen at brainkrash dot com
This appears to happen when php is compiled in non-debug mode. APD profiles correctly when compiled with the --enable-debug option.
 [2006-07-23 20:29 UTC] seufert at gmail dot com
I have the same problem, with lastest debian testing package for php5-cli (PHP 5.1.4) on AMD64. Once you enable this extension, i get random Segmentation Faults, just running working scripts.

Is there any hope of this being fixed in the near future?
 [2006-07-23 21:14 UTC] seufert at gmail dot com
Upon further investigation, i have discovered, the main problem seems to be including files, with no includes my segfaults dissapear.

<?php
apd_set_pprof_trace(); 
include "phpinfo.php";
?>
phpinfo.php
<?php phpinfo(); ?>

I have had a play using eval rather than include, gives the same segfaults.
 [2007-09-28 18:39 UTC] agottschalk at letstalk dot com
Confirmed with PHP 4.4.7 compiled from source with standard CLI options.

$ cat segfault.php 
<?php
apd_set_pprof_trace();
echo "Hello, world!\n";
?>

$ php -e ./segfault.php
Hello, world!
Segmentation fault

Creates an empty file named pprof.<pid>.0
 [2008-01-25 18:27 UTC] vk at vskm dot org
This still seems to be a problem. Can't get it to work on a standard Ubuntu 7.10 installation.

$ php  -r "apd_set_pprof_trace();"
Segmentation fault (core dumped)

$ php --version
PHP 5.2.3-1ubuntu6.3 (cli) (built: Jan 10 2008 09:38:37)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
    with Advanced PHP Debugger (APD) v0.9, , by George Schlossnagle
 [2008-02-11 08:20 UTC] deejayy at vipmail dot hu
# wget http://pecl.php.net/get/apd-1.0.1.tgz
# tar zxfv apd-1.0.1.tgz
# phpize
# ./configure --enable-apd=shared
# make

# cp modules/apd.so /usr/lib/php5/20060613/

# echo zend_extension=/usr/lib/php5/20060613/apd.so > /etc/php5/conf.d/apd.ini
# echo apd.dumpdir = /tmp/apd >> /etc/php5/conf.d/apd.ini

# uname -a
Linux * 2.6.18.2 #1 SMP PREEMPT Thu Nov 9 21:48:58 CET 2006 x86_64 GNU/Linux

# php -v
PHP 5.2.1-0.dotdeb.1 with Suhosin-Patch 0.9.6.2 (cli) (built: Feb  9 2007 04:13:18)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
    with Advanced PHP Debugger (APD) v0.9, , by George Schlossnagle

# echo '<? apd_set_pprof_trace(); printf("helo\n"); ?>' | php
helo
Segmentation fault

# ls -alp /tmp/apd/
total 8
drwxrwxrwx  2 root root 4096 2008-02-11 14:17 ./
drwxrwxrwt 11 root root 4096 2008-02-11 14:18 ../
-rw-r--r--  1 root root    0 2008-02-11 13:28 pprof.10292.0
-rw-r--r--  1 root root    0 2008-02-11 14:17 pprof.15631.0
-rw-r--r--  1 root root    0 2008-02-11 14:17 pprof.15641.0
-rw-r--r--  1 root root    0 2008-02-11 14:17 pprof.15645.0
-rw-r--r--  1 root root    0 2008-02-11 10:28 pprof.23626.0
 [2008-07-10 05:27 UTC] jbq at caraldi dot com
Same here, with or without PHP's DEBUG mode:

zend_extension_debug=/usr/lib/php5/20060613-debug/apd.so
apd.dumpdir=.

PHP 5.2.5-3caraldi2 with Suhosin-Patch 0.9.6.2 (cli) (built: Jul 10 2008 10:31:46) (DEBUG)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
    with Advanced PHP Debugger (APD) v0.9, , by George Schlossnagle
    with Xdebug v2.0.3, Copyright (c) 2002-2007, by Derick Rethans


Program terminated with signal 11, Segmentation fault.
[New process 11112]
#0  0x0000000000740572 in zend_get_executed_lineno () at /home/jbq/packages/php5-debug/Zend/zend_execute_API.c:394
394                     return active_opline->lineno;
(gdb) bt
#0  0x0000000000740572 in zend_get_executed_lineno () at /home/jbq/packages/php5-debug/Zend/zend_execute_API.c:394
#1  0x00007f11b9fd50bc in log_time () at /tmp/pear/cache/apd-1.0.1/php_apd.c:424
#2  0x00007f11b9fd5675 in trace_function_exit (fname=0x1193710 "require_once") at /tmp/pear/cache/apd-1.0.1/php_apd.c:399
#3  0x00007f11b9fd648f in apd_execute (op_array=0x1a0f468) at /tmp/pear/cache/apd-1.0.1/php_apd.c:519
#4  0x00007f11b9da503c in xdebug_execute (op_array=0x1a0f468) at /tmp/pear/cache/xdebug-2.0.3/xdebug.c:1541
#5  0x0000000000784660 in ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER (execute_data=Cannot access memory at address 0x8000c5820f98
) at /home/jbq/packages/php5-debug/Zend/zend_vm_execute.h:2039
#6  0x000000000077c972 in execute (op_array=Cannot access memory at address 0x8000c5821128
) at /home/jbq/packages/php5-debug/Zend/zend_vm_execute.h:92
#7  0x00007f11b9fd6487 in apd_execute (op_array=0xf89598) at /tmp/pear/cache/apd-1.0.1/php_apd.c:518
#8  0x00007f11b9da503c in xdebug_execute (op_array=0xf89598) at /tmp/pear/cache/xdebug-2.0.3/xdebug.c:1541
#9  0x0000000000784660 in ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER (execute_data=Cannot access memory at address 0x8000c58212d8
) at /home/jbq/packages/php5-debug/Zend/zend_vm_execute.h:2039
#10 0x000000000077c972 in execute (op_array=Cannot access memory at address 0x8000c5821a58
) at /home/jbq/packages/php5-debug/Zend/zend_vm_execute.h:92
#11 0x00007f11b9fd6487 in apd_execute (op_array=0x1a0e2e8) at /tmp/pear/cache/apd-1.0.1/php_apd.c:518
#12 0x00007f11b9da503c in xdebug_execute (op_array=0x1a0e2e8) at /tmp/pear/cache/xdebug-2.0.3/xdebug.c:1541
#13 0x000000000077d10b in zend_do_fcall_common_helper_SPEC (execute_data=Cannot access memory at address 0x8000c5821c20
) at /home/jbq/packages/php5-debug/Zend/zend_vm_execute.h:234
#14 0x000000000077ddfc in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER (execute_data=Cannot access memory at address 0x8000c5821c98
) at /home/jbq/packages/php5-debug/Zend/zend_vm_execute.h:322
#15 0x000000000077c972 in execute (op_array=Cannot access memory at address 0x8000c5821e88
) at /home/jbq/packages/php5-debug/Zend/zend_vm_execute.h:92
#16 0x00007f11b9fd6487 in apd_execute (op_array=0xf87c98) at /tmp/pear/cache/apd-1.0.1/php_apd.c:518
#17 0x00007f11b9da503c in xdebug_execute (op_array=0xf87c98) at /tmp/pear/cache/xdebug-2.0.3/xdebug.c:1541
#18 0x0000000000752e02 in zend_execute_scripts (type=Cannot access memory at address 0x8000c582205c
) at /home/jbq/packages/php5-debug/Zend/zend.c:1215
#19 0x00000000006f1f00 in php_execute_script (primary_file=Cannot access memory at address 0x8000c58231c8
) at /home/jbq/packages/php5-debug/main/main.c:2025
#20 0x00000000007e4339 in main (argc=Cannot access memory at address 0x8000c58243fc
) at /home/jbq/packages/php5-debug/sapi/cli/php_cli.c:1146
 [2008-07-24 01:43 UTC] mattnyc at nyc dot rr dot com
Same problem here.  It looks like this bug hasn't been fixed in years.  Is there another option for PHP performance analysis?
 [2008-07-24 02:40 UTC] mattnyc at nyc dot rr dot com
To answer my own question:  YES.  http://xdebug.org/docs/profiler.  I installed it and it seems to work well.
 [2010-02-02 07:16 UTC] webmail5555 at gmail dot com
Looks like APD is a discontinued project.

I can confirm segmentation faults on all my boxes, various php versions.

I suggest to stay away from it.
 [2010-04-08 04:54 UTC] arik_harel at walla dot co dot il
Just add  exit(0); in the end of the code and it should 
work.
The result of the profiler is stored under /tmp/
pprofp -R /tmp/pprof.XXX.0 //Where XXX is job id

1. Code:
<?php
apd_set_pprof_trace();
print "hello world\n";
 exit(0);
?>

2. Than did:
ll /tmp/
And found the last pprof.XXX.0 file
Mine was:  pprof.32764.0

3. pprofp -R /tmp/pprof.32764.0
Result:

       Real         User        System             secs/    
cumm
%Time (excl/cumm)  (excl/cumm)  (excl/cumm) Calls    call    
s/call  Memory Usage Name
------------------------------------------------------------
--------------------------
100.0 0.00 0.00  0.00 0.00  0.00 0.00     1  0.0004   0.0004   
1572864000 apd_set_pprof_trace
100.0 0.00 0.00  0.00 0.00  0.00 0.00     1  0.0000   0.0004            
0 main
 [2012-03-01 11:45 UTC] gastunixadmin2 at inv dot it dot uc3m dot es
Thanks arik, your solution works perfect.
 [2015-02-26 07:33 UTC] krakjoe@php.net
-Status: Open +Status: Suspended
 [2015-02-26 07:33 UTC] krakjoe@php.net
APD hasn't had a release in 10 years, this means it's source code is way out of sync with modern PHP.

I'm going to mark this bug as suspended, the report can still be found if a maintainer for APD comes forward.

Sorry about the wait.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 09:01:28 2024 UTC