Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 211611

Summary: >=dev-lang/php-5.2.5_p20080206: segfault on x86 with pg_connect() when compiled w/ -O3
Product: Gentoo Linux Reporter: Christian Schneider <mail>
Component: New packagesAssignee: PHP Bugs <php-bugs>
Status: RESOLVED NEEDINFO    
Severity: normal CC: mail
Priority: High    
Version: unspecified   
Hardware: x86   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Christian Schneider 2008-02-27 11:14:01 UTC
PHP segfaults when connecting to any (existing or non-existing) PostgreSQL database (=dev-db/postgresql-8.0.15). 

I tried:
=dev-lang/php-5.2.5_p20080206,
=dev-lang/php-5.2.5_p20080206-r2,
=dev-lang/php-5.2.5_p20080206-r3
without success.

Only =dev-lang/php-5.2.5-r1 works for me.

Reproducible: Always

Steps to Reproduce:
1. Execute: php -r 'pg_connect("dbname=foobar user=general");'
Actual Results:  
Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL:  database "foobar" does not exist in Command line code on line 1
Segmentation fault
Comment 1 Christian Schneider 2008-02-27 11:16:28 UTC
Portage 2.1.4.4 (default-linux/x86/2007.0, gcc-3.4.6, glibc-2.6.1-r0, 2.6.23-gentoo-r8 i686)
=================================================================
System uname: 2.6.23-gentoo-r8 i686 Intel(R) Pentium(R) 4 CPU 3.00GHz
Timestamp of tree: Wed, 27 Feb 2008 08:46:01 +0000
app-shells/bash:     3.2_p17-r1
dev-lang/python:     2.3.5-r3, 2.4.4-r6
dev-python/pycrypto: 2.0.1-r6
sys-apps/baselayout: 1.12.11.1
sys-apps/sandbox:    1.2.18.1-r2
sys-devel/autoconf:  2.13, 2.61-r1
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10
sys-devel/binutils:  2.18-r1
sys-devel/gcc-config: 1.4.0-r4
sys-devel/libtool:   1.5.26
virtual/os-headers:  2.6.23-r3
ACCEPT_KEYWORDS="x86"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O3 -march=pentium4 -funroll-loops -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.4/env /usr/kde/3.4/share/config /usr/kde/3.4/shutdown /usr/share/config"
CONFIG_PROTECT_MASK="/etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/terminfo /etc/texmf/web2c /etc/udev/rules.d"
CXXFLAGS="-O3 -march=pentium4 -funroll-loops -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="ccache distlocks metadata-transfer sandbox sfperms strict unmerge-orphans userfetch"
GENTOO_MIRRORS="http://mirrors.sec.informatik.tu-darmstadt.de/gentoo/"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/portage.local"
SYNC="rsync://mirrors.sec.informatik.tu-darmstadt.de/gentoo-portage"
USE="acl apache2 avi berkdb bitmap-fonts cli cracklib crypt doc dri dvd encode fortran gdbm gpm iconv idea imap ipv6 isdnlog jpeg ldap midi mmx mudflap mysqli ncurses nls nptl nptlonly oggvorbis openmp pam pcre perl png pppd python readline reflection sdk session spl ssl tcltk tcpd truetype-fonts type1-fonts x86 xml xmlreader xmlwriter xorg xv zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="access actions alias asis auth auth_anon auth_basic auth_dbm auth_digest authn_alias authn_anon authn_default authn_file authz_default authz_host authz_owner authz_user autoindex autoindex cache cern_meta cgi cgid charset_lite dav dav_fs dav_lock deflate dir disk_cache echo env expires ext-filter file_cache filter headers imap include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif so speling status userdir" ELIBC="glibc" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" USERLAND="GNU" VIDEO_CARDS="apm ark chips cirrus cyrix dummy fbdev glint i128 i740 i810 imstt mach64 mga neomagic nsc nv r128 radeon rendition s3 s3virge savage siliconmotion sis sisusb tdfx tga trident tseng v4l vesa vga via vmware voodoo"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, LINGUAS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

Comment 2 Jakub Moc (RETIRED) gentoo-dev 2008-02-27 11:19:01 UTC
Need a list of all extensions enabled and a backtrace.

http://www.gentoo.org/proj/en/qa/backtraces.xml
Comment 3 Christian Schneider 2008-02-27 19:17:12 UTC
During recompiling the debug version von PHP, I realized that it seems to be the CFLAGS="-O3" that leads to the segfault. When compiling PHP with CFLAGS="-O2", no segfault occures.

Nevertheless, here is the requested information:

$ eix -p dev-lang/php
[I] dev-lang/php
     Available versions:
        (4)     [M]4.4.8_pre20070816 [M]~4.4.8
        (5)     5.2.4_pre200708051230-r2 5.2.5-r1 {M}5.2.5_p20080206 (~)5.2.5_p20080206-r2 5.2.5_p20080206-r3
        {adabas apache2 bcmath berkdb birdstep bzip2 calendar cdb cgi cjk cli concurrentmodphp crypt ctype curl curlwrappers db2 dbase dbmaker dbx debug discard-path doc empress empress-bcs esoob exif expat fastbuild fdftk filepro filter firebird flatfile force-cgi-redirect frontbase ftp gd gd-external gdbm gmp hash hyperwave-api iconv imap informix inifile interbase iodbc ipv6 java-external java-internal json kerberos ldap ldap-sasl libedit mcal mcve memlimit mhash ming mnogosearch msql mssql mysql mysqli ncurses nls oci8 oci8-instant-client odbc oracle7 overload pcntl pcre pdo pfpro pic posix postgres qdbm readline recode reflection sapdb session sharedext sharedmem simplexml snmp soap sockets solid spell spl sqlite ssl suhosin sybase sybase-ct sysvipc threads tidy tokenizer truetype unicode wddx xml xmlreader xmlrpc xmlwriter xpm xsl yaz zip zip-external zlib}
     Installed versions:  5.2.5_p20080206-r3(5)(20:07:53 02/27/08)(apache2 berkdb cli crypt ctype doc gdbm iconv imap ipv6 ldap mysql mysqli ncurses nls pcre postgres readline reflection session spl ssl unicode xml xmlreader xmlwriter zlib -adabas -bcmath -birdstep -bzip2 -calendar -cdb -cgi -cjk -concurrentmodphp -curl -curlwrappers -db2 -dbase -dbmaker -debug -discard-path -empress -empress-bcs -esoob -exif -fastbuild -fdftk -filter -firebird -flatfile -force-cgi-redirect -frontbase -ftp -gd -gd-external -gmp -hash -inifile -interbase -iodbc -java-external -json -kerberos -ldap-sasl -libedit -mcve -mhash -msql -mssql -oci8 -oci8-instant-client -odbc -pcntl -pdo -pic -posix -qdbm -recode -sapdb -sharedext -sharedmem -simplexml -snmp -soap -sockets -solid -spell -sqlite -suhosin -sybase -sybase-ct -sysvipc -threads -tidy -tokenizer -truetype -wddx -xmlrpc -xpm -xsl -yaz -zip -zip-external)





$ gdb --args /usr/bin/php -r ' pg_connect("dbname=rscds user=general");'
GNU gdb 6.7.1
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) run
Starting program: /usr/bin/php -r \ pg_connect\(\"dbname=rscds\ user=general\"\)\;
[Thread debugging using libthread_db enabled]
[New Thread 0xb76496c0 (LWP 14609)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb76496c0 (LWP 14609)]
0x082aca7c in _zval_ptr_dtor (zval_ptr=0xbffdc500)
    at /var/tmp/portage/dev-lang/php-5.2.5_p20080206-r3/work/php-5.2.5_p20080206/Zend/zend_execute_API.c:412
412     /var/tmp/portage/dev-lang/php-5.2.5_p20080206-r3/work/php-5.2.5_p20080206/Zend/zend_execute_API.c: No such file or directory.
        in /var/tmp/portage/dev-lang/php-5.2.5_p20080206-r3/work/php-5.2.5_p20080206/Zend/zend_execute_API.c
(gdb) bt
#0  0x082aca7c in _zval_ptr_dtor (zval_ptr=0xbffdc500)
    at /var/tmp/portage/dev-lang/php-5.2.5_p20080206-r3/work/php-5.2.5_p20080206/Zend/zend_execute_API.c:412
#1  0x082e6615 in zend_do_fcall_common_helper_SPEC (execute_data=0xbffdc580)
    at /var/tmp/portage/dev-lang/php-5.2.5_p20080206-r3/work/php-5.2.5_p20080206/Zend/zend_execute.h:155
#2  0x082e60cc in execute (op_array=0xbffdc584)
    at /var/tmp/portage/dev-lang/php-5.2.5_p20080206-r3/work/php-5.2.5_p20080206/Zend/zend_vm_execute.h:92
#3  0x082b006e in zend_eval_string (str=0x8746940 "\004it\b", retval_ptr=0x0, string_name=0x0)
    at /var/tmp/portage/dev-lang/php-5.2.5_p20080206-r3/work/php-5.2.5_p20080206/Zend/zend_execute_API.c:1171
#4  0x082b0208 in zend_eval_string_ex (str=0x0, retval_ptr=0x0, string_name=0x0, handle_exceptions=1)
    at /var/tmp/portage/dev-lang/php-5.2.5_p20080206-r3/work/php-5.2.5_p20080206/Zend/zend_execute_API.c:1205
#5  0x08361840 in main (argc=3, argv=0xbffdca24)
    at /var/tmp/portage/dev-lang/php-5.2.5_p20080206-r3/work/php-5.2.5_p20080206/sapi/cli/php_cli.c:1229
(gdb) 
Comment 4 Jakub Moc (RETIRED) gentoo-dev 2008-02-27 19:27:34 UTC
With -O3 and without -funroll-loops is happens as well?