php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34725 CLI segmentation faults during cleanup
Submitted: 2005-10-04 08:38 UTC Modified: 2005-10-28 10:31 UTC
From: david at tulloh dot id dot au Assigned: dmitry
Status: Closed Package: Scripting Engine problem
PHP Version: 5.1.0RC3 OS: Debian Linux
Private report: No CVE-ID:
 [2005-10-04 08:38 UTC] david at tulloh dot id dot au
Description:
------------
Using the 5.1 branch.

PHP segmentation faults at the end of running the simplest code.

Reproduce code:
---------------
<?php
echo 'hello world';
?>

(CLI)

Actual result:
--------------
hello world is printed perfectly, after the PHP program completes the segmentation fault occurs:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1211463456 (LWP 25258)]
0xb7a88840 in ?? ()
(gdb) bt
#0  0xb7a88840 in ?? ()
#1  0x08131730 in tsrm_shutdown () at php-cvs-5.1/TSRM/TSRM.c:180
#2  0x081f425d in main (argc=2, argv=0xbffffb94)
    at php-cvs-5.1/sapi/cli/php_cli.c:1152


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-04 08:41 UTC] sniper@php.net
What was the configure line you used?

 [2005-10-04 09:10 UTC] david at tulloh dot id dot au
./configure \
    '--enable-cli' \
    '--with-pear' \
    '--disable-cgi' \
    '--prefix=/usr'\
    '--with-apxs2=/usr/bin/apxs2' \
    '--with-config-file-path=/etc/php5' \
    '--enable-memory-limit' \
    '--enable-sysvsem' \
    '--enable-sysvshm' \
    '--enable-sysvmsg' \
    '--enable-sockets' \
    '--enable-bcmath' \
    '--enable-calendar' \
    '--enable-shmop' \
    '--enable-libxml' \
    '--enable-xml' \
    '--enable-spl' \
    '--with-layout=GNU' \
    '--with-inifile' \
    '--with-exec-dir=/usr/lib/php5/libexec' \
    '--with-regex=php' \
    '--with-libxml-dir=/usr' \
    '--with-zlib' \
    '--with-zlib-dir=/usr' \
    '--with-gettext' \
    '--with-kerberos=shared,/usr' \
    '--with-mime-magic=/usr/share/php5/magic.mime' \
    '--with-pcre-regex=shared,/usr' \
    '--with-pgsql=shared,/usr' \
    '--with-tidy' \
    '--disable-rpath' \
    '--disable-debug' \
    '--disable-dbx' \
    '--disable-filepro' \
    '--disable-gd-native-ttf' \
    '--disable-gd-jis-conv' \
    '--disable-dom' \
    '--disable-exif' \
    '--disable-simplexml' \
    '--disable-ftp' \
    '--disable-pdo' \
    '--without-mm' \
    '--without-iconv' \
    '--without-sqlite' \
    '--without-mysql' \
    '--without-sybase-ct' \
    '--without-gdbm' \
    '--without-db4' \
    '--without-cdb' \
    '--without-flatfile' \
    "$@"
 [2005-10-04 09:16 UTC] sniper@php.net
Try with this configure line:

# ./configure --disable-all --disable-cgi

And if that works, add the --with/--enable options
one by one. And read "./configure --help" what the
options actually do, f.e. --with-kerberos=shared ?? What are you trying to accomplish with that? There is no such extension, it's just "helper" option..

 [2005-10-12 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2005-10-17 10:13 UTC] david at tulloh dot id dot au
I managed to track this down to a much more specific test case.  The following configure line is the smallest reproducable test case I could find.

./configure \
        '--disable-all' \
        '--enable-cli' \
        '--disable-cgi' \
        '--with-apxs2=/usr/bin/apxs2' \
        '--with-pcre-regex=shared,/usr'

Removing the apxs2 line, or making the pcre extension non-shared hides the fault, it's also not visible if the pcre extension isn't loaded.

The tests were done with the latest CVS version, 5.1 branch.

apache2-mpm-prefork (debian stable) - 2.0.54
libpcre3 - 5.0
 [2005-10-17 12:33 UTC] tony2001@php.net
Use valgrind to get some more info about it.
 [2005-10-26 11:03 UTC] david at tulloh dot id dot au
I finished the valgrind run, I've hosted the log files as they were a little bigish.

http://tulloh.id.au/php/bugs/34725/pass.valgrind
http://tulloh.id.au/php/bugs/34725/fail.valgrind

Some related files (config & test file) are also in the directory.
 [2005-10-26 11:08 UTC] tony2001@php.net
What if you ,/configure PHP with --enable-debug ?
Are you still able to replicate it?
If yes, please generate gdb backtrace using debug build and repeat with valgrind too.
 [2005-10-27 04:59 UTC] david at tulloh dot id dot au
Repeated with --enable-debug

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1210001728 (LWP 23835)]
0xb7c07840 in ?? ()
(gdb) bt
#0  0xb7c07840 in ?? ()
#1  0x080e5ce0 in tsrm_shutdown () at php-cvs-5.1/TSRM/TSRM.c:180
#2  0x081a82f4 in main (argc=3, argv=0xbffffb54)
    at php-cvs-5.1/sapi/cli/php_cli.c:1155

http://tulloh.id.au/php/bugs/34725/fail.debug.valgrind
 [2005-10-28 09:25 UTC] dmitry@php.net
The problem is related to TSRM and ext/pcre that registers its globals with shutdown handler:

ZEND_INIT_MODULE_GLOBALS(pcre, php_pcre_init_globals, php_pcre_shutdown_globals);

PHP tries to call php_pcre_shutdown_globals() after it unloads ext/pcre and crashes.

I'll look if it is possible to fix this, but may be it is not possible.
As work around I recomend not to compile ext/pcre as DSO.
 
 [2005-10-28 10:31 UTC] dmitry@php.net
Fixed in CVS HEAD and PHP_5_1.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 17 03:01:55 2014 UTC