segfault from php/freebsd/dtrace

From: Oleg Ginzburg <olevole_at_olevole.ru>
Date: Thu, 29 Dec 2011 21:37:33 +0400
Hi maillist,

I try to use dtrace + php/dtrace on the freebsd. In certain cases ive get 
Segmentation fault and don't understand what of subsystem has a problem.

For this purpose:

1) have PHP with DTrace probes, for example:

svn co https://svn.php.net/repository/php/php-src/trunk php-trunk
php-trunk/buildconf  ( needs bison && re2c )
php-trunk/configure --enable-dtrace
( then bulds as usual)

2) have FreeBSD with world/kernel Dtrace support
3) Run php for providing dtrace/php probes

% php

4) Execute dtrace with PHP probes, for example, watch the errors:

% dtrace -s /dev/stdin

#pragma D option quiet

php*:::error
{
   printf("Error: %s in line %d (%s)\n", copyinstr(arg0), arg2,
copyinstr(arg1));
}

^D


4) Run PHP with some error, for example:
% php -E "thisisit"
^D

Result:

Dtrace ouput (this is ok):
Error: syntax error, unexpected end of file in line 1 (Command line end code)

% php -E "thisisit"
Segmentation fault (core dumped)


% gdb -c ./php.core /usr/local/bin/php
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "amd64-marcel-freebsd"...(no debugging symbols
found)...
Core was generated by `php'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/lib/libelf.so.1...(no debugging symbols
found)...done.
Loaded symbols for /usr/lib/libelf.so.1
Reading symbols from /lib/libcrypt.so.5...(no debugging symbols found)...done.
Loaded symbols for /lib/libcrypt.so.5
Reading symbols from /lib/libz.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib/libz.so.6
Reading symbols from /usr/local/lib/libpcre.so.0...(no debugging symbols
found)...done.
Loaded symbols for /usr/local/lib/libpcre.so.0
Reading symbols from /usr/lib/librt.so.1...(no debugging symbols
found)...done.
Loaded symbols for /usr/lib/librt.so.1
Reading symbols from /lib/libm.so.5...(no debugging symbols found)...done.
Loaded symbols for /lib/libm.so.5
Reading symbols from /usr/local/lib/libxml2.so.5...(no debugging symbols
found)...done.
Loaded symbols for /usr/local/lib/libxml2.so.5
Reading symbols from /usr/local/lib/libiconv.so.3...(no debugging symbols
found)...done.
Loaded symbols for /usr/local/lib/libiconv.so.3
Reading symbols from /lib/libthr.so.3...(no debugging symbols found)...done.
Loaded symbols for /lib/libthr.so.3
Reading symbols from /lib/libc.so.7...(no debugging symbols found)...done.
Loaded symbols for /lib/libc.so.7
Reading symbols from /libexec/ld-elf.so.1...(no debugging symbols
found)...done.
Loaded symbols for /libexec/ld-elf.so.1
#0  0x00000008021c6a37 in strlen () from /lib/libc.so.7
[New Thread 802807400 (LWP 100326/php)]


(gdb) file
No executable file now.
/usr/src/gnu/usr.bin/gdb/libgdb/fbsd-threads.c:484: internal-error:
fbsd_thread_new_objfile: Assertion `proc_handle.pid == 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) n
/usr/src/gnu/usr.bin/gdb/libgdb/fbsd-threads.c:484: internal-error:
fbsd_thread_new_objfile: Assertion `proc_handle.pid == 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) n

(gdb) bt
#0  0x00000008021c6a37 in ?? () from /lib/libc.so.7
/usr/src/gnu/usr.bin/gdb/libgdb/../../../../contrib/gdb/gdb/dwarf2-
frame.c:613: internal-error: dwarf2_frame_cache: Assertion `fde != NULL'
failed.


Backtrace for php.core:
fbsd-strace# gdb -c ./php.core /usr/local/bin/php
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "amd64-marcel-freebsd"...(no debugging symbols
found)...
Core was generated by `php'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/lib/libelf.so.1...(no debugging symbols
found)...done.
Loaded symbols for /usr/lib/libelf.so.1
Reading symbols from /lib/libcrypt.so.5...(no debugging symbols found)...done.
Loaded symbols for /lib/libcrypt.so.5
Reading symbols from /lib/libz.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib/libz.so.6
Reading symbols from /usr/local/lib/libpcre.so.0...(no debugging symbols
found)...done.
Loaded symbols for /usr/local/lib/libpcre.so.0
Reading symbols from /usr/lib/librt.so.1...(no debugging symbols
found)...done.
Loaded symbols for /usr/lib/librt.so.1
Reading symbols from /lib/libm.so.5...(no debugging symbols found)...done.
Loaded symbols for /lib/libm.so.5
Reading symbols from /usr/local/lib/libxml2.so.5...(no debugging symbols
found)...done.
Loaded symbols for /usr/local/lib/libxml2.so.5
Reading symbols from /usr/local/lib/libiconv.so.3...(no debugging symbols
found)...done.
Loaded symbols for /usr/local/lib/libiconv.so.3
Reading symbols from /lib/libthr.so.3...(no debugging symbols found)...done.
Loaded symbols for /lib/libthr.so.3
Reading symbols from /lib/libc.so.7...(no debugging symbols found)...done.
Loaded symbols for /lib/libc.so.7
Reading symbols from /libexec/ld-elf.so.1...(no debugging symbols
found)...done.
Loaded symbols for /libexec/ld-elf.so.1
#0  0x00000008021c6a37 in strlen () from /lib/libc.so.7
[New Thread 802807400 (LWP 100326/php)]
(gdb) bt
#0  0x00000008021c6a37 in strlen () from /lib/libc.so.7
#1  0x0000000000511b7a in vspprintf ()
#2  0x000000000050ecd7 in php_error_cb ()
#3  0x0000000000568ba4 in zend_error_noreturn ()
#4  0x000000000052e414 in zendparse ()
#5  0x000000000053c8fb in compile_string ()
#6  0x000000000055b523 in zend_eval_stringl ()
#7  0x000000000055b799 in zend_eval_stringl_ex ()
#8  0x000000000060bee0 in do_cli ()
#9  0x000000000060c6b4 in main ()
#10 0x0000000000419bbe in _start ()
#11 0x000000080098b000 in ?? ()
#12 0x0000000000000000 in ?? ()
#13 0x0000000000000003 in ?? ()
#14 0x00007fffffffdde8 in ?? ()
#15 0x00007fffffffddec in ?? ()
#16 0x00007fffffffddef in ?? ()
#17 0x0000000000000000 in ?? ()
#18 0x00007fffffffddf8 in ?? ()
#19 0x00007fffffffde03 in ?? ()
#20 0x00007fffffffde18 in ?? ()
#21 0x00007fffffffde24 in ?? ()
#22 0x00007fffffffde38 in ?? ()
#23 0x00007fffffffde8f in ?? ()
#24 0x00007fffffffde9e in ?? ()
#25 0x00007fffffffdea9 in ?? ()
#26 0x00007fffffffdeb3 in ?? ()
#27 0x00007fffffffdec4 in ?? ()
#28 0x00007fffffffded3 in ?? ()
#29 0x00007fffffffdee2 in ?? ()
#30 0x00007fffffffdef3 in ?? ()
#31 0x00007fffffffdefb in ?? ()
#32 0x00007fffffffdf0f in ?? ()
#33 0x00007fffffffdf1c in ?? ()
#34 0x00007fffffffdf28 in ?? ()
#35 0x00007fffffffdf43 in ?? ()
#36 0x00007fffffffdf5a in ?? ()
#37 0x00007fffffffdf64 in ?? ()
#38 0x0000000000000000 in ?? ()
#39 0x0000000000000003 in ?? ()
#40 0x0000000000400040 in ?? ()
#41 0x0000000000000004 in ?? ()
#42 0x0000000000000038 in ?? ()
#43 0x0000000000000005 in ?? ()
#44 0x0000000000000008 in ?? ()
#45 0x0000000000000006 in ?? ()
#46 0x0000000000001000 in ?? ()
#47 0x0000000000000008 in ?? ()
#48 0x0000000000000000 in ?? ()
#49 0x0000000000000009 in ?? ()
#50 0x0000000000419b30 in ?? ()
#51 0x0000000000000007 in ?? ()
#52 0x0000000800951000 in ?? ()
#53 0x000000000000000f in ?? ()
#54 <signal handler called>
#55 0x0000000000000000 in ?? ()
Previous frame inner to this frame (corrupt stack?)


In a case when php it is compiled with debug symbols, Segfault is absent.


--//Cut of /usr/src/gnu/usr.bin/gdb/libgdb/fbsd-threads.c//--
static void
fbsd_thread_new_objfile (struct objfile *objfile)
{
 td_err_e err;

 if (objfile == NULL)
   {
     /* All symbols have been discarded.  If the thread_db target is
        active, deactivate it now.  */
     if (fbsd_thread_active)
       {
         gdb_assert (proc_handle.pid == 0); <<   Here is 484 string mentioned 
by backtrace <<
         fbsd_thread_active = 0;
       }

     goto quit;
   }

--//End of Cut//--

There are the ideas, what the part can cause a problem? 
Received on Thu Dec 29 2011 - 16:37:00 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:22 UTC