php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26977 PCRE related segmentation fault
Submitted: 2004-01-20 07:20 UTC Modified: 2004-01-20 19:07 UTC
From: martijn at grendelman dot net Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 4.3.4 OS: Debian Linux (testing)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: martijn at grendelman dot net
New email:
PHP Version: OS:

 

 [2004-01-20 07:20 UTC] martijn at grendelman dot net
Description:
------------
PHP crashes when using PEAR-DB. Looks like a problem with PCRE.

'./configure' '--prefix=/usr/local' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-regex=php' '--with-config-file-path=/usr/local/apache2/conf' '--disable-rpath' '--disable-debug' '--enable-memory-limit' '--enable-calendar' '--enable-sysvsem' '--enable-sysvshm' '--enable-track-vars' '--enable-trans-sid' '--enable-bcmath' '--with-bz2' '--enable-ctype' '--with-iconv' '--enable-exif' '--enable-ftp' '--enable-mbstring' '--with-pcre-regex=/usr' '--enable-shmop' '--enable-sockets' '--enable-wddx' '--with-xml=/usr' '--with-expat-dir=/usr' '--enable-yp' '--with-zlib' '--without-pgsql' '--disable-static' '--with-layout=GNU' '--with-curl=shared,/usr' '--with-dom=shared,/usr' '--with-zlib-dir=/usr' '--with-gd=shared,/usr' '--with-jpeg-dir=shared,/usr' '--with-xpm-dir=shared,/usr/X11R6' '--with-png-dir=shared,/usr' '--with-freetype-dir=shared,/usr' '--with-imap=shared,/usr' '--with-ldap=shared,/usr' '--with-mcal=shared,/usr' '--with-mhash=shared,/usr' '--with-mysql=shared,/usr' '--with-unixODBC=shared,/usr' '--enable-xslt' '--with-xslt-sablot=shared,/usr' '--with-ttf=shared,/usr' '--with-t1lib=shared,/usr' '--with-kerberos' '--enable-debug'

So, the PCRE library in /usr (from Debian) is used.

php.ini:
;extension=gd.so
extension=imap.so
;extension=curl.so
extension=ldap.so
extension=mysql.so
;extension=domxml.so
;extension=mcal.so
;extension=mhash.so
;extension=odbc.so

so not all shared modules are loaded.

pcre
PCRE (Perl Compatible Regular Expressions) Support 	enabled
PCRE Library Version 	3.9 02-Jan-2002

(gdb) run -X
Starting program: /usr/local/apache2/bin/httpd -X
[New Thread 1077983808 (LWP 24414)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1077983808 (LWP 24414)]
0x404c29d6 in php_pcre_match (ht=3, return_value=0x81df3f4, this_ptr=0x0, return_value_used=1, global=0)
    at /extra0/home/martijn/src/php-4.3.4/ext/pcre/php_pcre.c:442
442                                     name_idx = 0xff * name_table[0] + name_table[1];


Reproduce code:
---------------
<?
  include "DB.php";  // PEAR

  define("DBTYPE","mysql");
  define("DBUSER","user");
  define("DBPASS","password");
  define("DBSERV","localhost");
  define("DB","mydb");

  $dsn = DBTYPE."://".DBUSER.":".DBPASS."@".DBSERV."/".DB;
  $dbc = DB::connect($dsn);
  if (DB::isError($dbc)) {
    $page="dberror";
  }
  else {
    $dbc->setFetchMode(DB_FETCHMODE_ASSOC);
  }
  echo "test";
?>


Expected result:
----------------
The word "test" should have been displayed.

Actual result:
--------------
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1077983808 (LWP 24414)]
0x404c29d6 in php_pcre_match (ht=3, return_value=0x81df3f4, this_ptr=0x0, return_value_used=1, global=0)
    at /extra0/home/martijn/src/php-4.3.4/ext/pcre/php_pcre.c:442
442                                     name_idx = 0xff * name_table[0] + name_table[1];


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-20 07:44 UTC] martijn at grendelman dot net
This problem looks fixable by omitting '--with-pcre-regex=/usr', thus linking against the bundled library.

I'd like to point out that I've seen this problem on two quite different environments:

1. Debian Stable, Linux kernel 2.4.23, Apache 1.3.26 + PHP 4.1.2 (Debian packages), PCRE library (as reported by phpinfo()) 3.4 22-Aug-2000.

2. Debian Testing, Linux kerel 2.6.1, Apache 2.0.47 + PHP 4.3.4 (compiled from source), PCRE library (as reported by phpinfo()) 3.9 02-Jan-2002
 [2004-01-20 19:07 UTC] sniper@php.net
Not PHP bug, PCRE bug. (ALWAYS use the bundled pcre lib if you don't know what you're doing)

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jun 23 07:01:31 2025 UTC