Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 351132 - dev-php5/pecl-htscanner-0.9.0-r1: SIGSEGV with php-5.2.17 (php-cgi)
Summary: dev-php5/pecl-htscanner-0.9.0-r1: SIGSEGV with php-5.2.17 (php-cgi)
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: High normal (vote)
Assignee: PHP Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-08 16:11 UTC by Clemens Renner
Modified: 2011-02-03 21:04 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Clemens Renner 2011-01-08 16:11:10 UTC
With release 0.9.0-r1 of pecl-htscanner, accessing a PHP page in apache-2.2.16 results in a segmentation fault apparently caused by pecl-htscanner. Apache displays error 500 and the error log tells me about "Premature end of script headers".

If I rename the extension htscanner.so file to e.g. .htscanner.so the problem goes away but of course .htaccess files are not evaluated anymore for PHP options.

The problem appeared first when I upgraded pecl-htscanner from 0.8.1 to 0.9.0-r1. I cannot go back to 0.8.1 because php-5.2.17 is blocking the earlier ebuild.

Here is a GDB trace I could produce by running php-cgi from the command line on an example file:

Program received signal SIGSEGV, Segmentation fault.
0x00000000005cf5fc in zend_hash_find (ht=0x50b9e0, arKey=0x6be02c "file", nKeyLength=5, pData=0x7fffffff9288) at /tmp/portage/dev-lang/php-5.2.17/work/sapis-build/cgi/Zend/zend_hash.c:880
880     /tmp/portage/dev-lang/php-5.2.17/work/sapis-build/cgi/Zend/zend_hash.c: No such file or directory.
        in /tmp/portage/dev-lang/php-5.2.17/work/sapis-build/cgi/Zend/zend_hash.c
(gdb) bt
#0  0x00000000005cf5fc in zend_hash_find (ht=0x50b9e0, arKey=0x6be02c "file", nKeyLength=5, pData=0x7fffffff9288) at /tmp/portage/dev-lang/php-5.2.17/work/sapis-build/cgi/Zend/zend_hash.c:880
#1  0x000000000058e5c9 in php_stream_locate_url_wrapper (path=0x7fffffff93a0 "./.htaccess", path_for_open=0x7fffffff9308, options=4, tsrm_ls=0x979180)
    at /tmp/portage/dev-lang/php-5.2.17/work/sapis-build/cgi/main/streams/streams.c:1641
#2  0x000000000058f99c in _php_stream_open_wrapper_ex (path=0x7fffffff93a0 "./.htaccess", mode=<value optimized out>, options=4, opened_path=0x0, context=0x0, tsrm_ls=0x979180)
    at /tmp/portage/dev-lang/php-5.2.17/work/sapis-build/cgi/main/streams/streams.c:1816
#3  0x00007ffff232b3bd in parse_config_file (tsrm_ls=0x979180) at /tmp/portage/dev-php5/pecl-htscanner-0.9.0-r1/work/php5.2/htscanner.c:232
#4  htscanner_main (tsrm_ls=0x979180) at /tmp/portage/dev-php5/pecl-htscanner-0.9.0-r1/work/php5.2/htscanner.c:441
#5  0x00007ffff232b71d in sapi_cgi_activate (tsrm_ls=0x979180) at /tmp/portage/dev-php5/pecl-htscanner-0.9.0-r1/work/php5.2/htscanner.c:465
#6  0x0000000000583064 in sapi_activate (tsrm_ls=0x979180) at /tmp/portage/dev-lang/php-5.2.17/work/sapis-build/cgi/main/SAPI.c:389
#7  0x0000000000579666 in php_request_startup (tsrm_ls=<value optimized out>) at /tmp/portage/dev-lang/php-5.2.17/work/sapis-build/cgi/main/main.c:1284
#8  0x00000000006417c1 in main (argc=<value optimized out>, argv=<value optimized out>) at /tmp/portage/dev-lang/php-5.2.17/work/sapis-build/cgi/sapi/cgi/cgi_main.c:1910

Note: to provide usable GDB output, I recompiled php and pecl-htscanner with FEATURES="nostrip"
and
CFLAGS="-O2 -march=athlon64 -ggdb"

Reproducible: Always

Steps to Reproduce:
Occurs when php-5.2.17 and pecl-htscanner-0.9.0-r1 should work together via php-cgi.



Portage 2.1.9.25 (default/linux/amd64/10.0, gcc-4.4.4, glibc-2.11.2-r3, 2.6.34-gentoo-r12-rinux3 x86_64)
=================================================================
System uname: Linux-2.6.34-gentoo-r12-rinux3-x86_64-Quad-Core_AMD_Opteron-tm-_Processor_1381-with-gentoo-1.12.14
Timestamp of tree: Sat, 08 Jan 2011 02:15:01 +0000
app-shells/bash:     4.1_p7
dev-java/java-config: 2.1.11-r1
dev-lang/python:     2.6.6-r1, 3.1.2-r4
dev-util/cmake:      2.8.1-r2
sys-apps/baselayout: 1.12.14-r1
sys-apps/sandbox:    2.4
sys-devel/autoconf:  2.13, 2.65-r1
sys-devel/automake:  1.10.3, 1.11.1
sys-devel/binutils:  2.20.1-r1
sys-devel/gcc:       4.3.4, 4.4.4-r2
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.10
sys-devel/make:      3.81-r2
virtual/os-headers:  2.6.30-r1 (sys-kernel/linux-headers)
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -funroll-loops -march=athlon64 -fomit-frame-pointer"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/php/apache2-php5.2/ext-active/ /etc/php/cgi-php5.2/ext-active/ /etc/php/cli-php5.2/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-O2 -pipe -funroll-loops -march=athlon64 -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests binpkg-logs distlocks fixlafiles fixpackages news parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
GENTOO_MIRRORS="http://linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror/ http://ftp-stud.fht-esslingen.de/pub/Mirrors/gentoo/ http://pandemonium.tiscali.de/pub/gentoo/ http://gentoo.intergenia.de"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="en_GB"
MAKEOPTS="-j6 -s"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
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="/var/lib/layman/webapps-experimental"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="3dnow a52 aac acl acpi amd64 berkdb bzip2 cli cracklib crypt cxx dri emul-linux-x86 exif fam flac ftp gdbm gif gnutls gpm hal iconv ipv6 java jpeg jpeg2k ldap libwww lm_sensors mad matroska mhash ming mmx modules mp3 mpeg mudflap multilib ncurses nls nptl nptlonly offensive ogg openmp pam pcre pdf perl png posix pppd readline ruby session sndfile spell sse sse2 ssl svg sysfs tcpd theora unicode vhosts vorbis wmf xorg xpm xvid zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci 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 mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic auth_digest authn_anon authn_dbd authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgid dav dav_fs dav_lock dbd deflate dir disk_cache env expires ext_filter file_cache filter headers ident imagemap include info log_config logio mem_cache mime mime_magic negotiation proxy proxy_ajp proxy_balancer proxy_connect proxy_http rewrite setenvif so speling status unique_id userdir usertrack vhost_alias" APACHE2_MPMS="worker" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en_GB" PHP_TARGETS="php5-2" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="fbdev glint intel mach64 mga neomagic nouveau nv r128 radeon savage sis tdfx trident vesa via vmware dummy v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Matti Bickel (RETIRED) gentoo-dev 2011-01-28 16:35:15 UTC
Sorry for having you wait a while. I tried to reproduce this error, but to no avail.

I normally don't use htscanner, so I'm certainly no expert here. Can you describe your setup?

Here's what I did:
* Emerged apache with mod_cgi
* copied/symlinked (either works) /usr/bin/php-cgi to /cgi-bin/php
* Added Handler and Action pointing to my files
* surfed to localhost/cgi-bin/test2.php (which was a leftover from a previous imagick test)
* enjoy

Do I need to have a .htaccess in cgi-bin to trigger the bug?

This is on php-5.2.17, apache-2.2.16, amd64
Comment 2 Clemens Renner 2011-01-29 13:44:59 UTC
(In reply to comment #1)
> I normally don't use htscanner, so I'm certainly no expert here. Can you
> describe your setup?
>
> Do I need to have a .htaccess in cgi-bin to trigger the bug?

Yes. htscanner enables user control of PHP flags for PHP in CGI mode. So the usual way to pass those flags with htscanner is to put a .htaccess file in the directory where the *.php files reside with contents like this:

<IfModule mod_php5.c>
php_flag  display_errors  Off
</IfModule>

I was able to bypass the issue when I renamed .htaccess to htaccess (to get it out of Apache's sight). Once I renamed the file back to its proper name, the problem reappeared.
Comment 3 Ole Markus With (RETIRED) gentoo-dev 2011-02-01 19:44:36 UTC
Upstream just released version 1.0.0. Seems like it contains quite a few changes, so it would be nice if you could test with this version (should be enter portage at the time of writing), that would be cool.
Comment 4 Clemens Renner 2011-02-03 21:00:00 UTC
I have just upgraded pecl-htscanner to version 1.0.0 which does not show this issue. It seems that the problem is resolved with this release. Thanks.
Comment 5 Ole Markus With (RETIRED) gentoo-dev 2011-02-03 21:04:19 UTC
Excellent :)