php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35304 PHP always segfaults with --without-sqlite
Submitted: 2005-11-20 12:57 UTC Modified: 2005-11-23 08:28 UTC
From: matteo at beccati dot com Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5CVS-2005-11-20 (snap) OS: Debian GNU/Linux testing/etch
Private report: No CVE-ID: None
 [2005-11-20 12:57 UTC] matteo at beccati dot com
Description:
------------
I was starting to test PHP5.1.0RC6.

make install was exiting with a segmentation fault, because running php from command line always exit with a segfault. I tracked down that the problem depends by the fact I used --without-sqlite in the configure options.

Using the php5-200511200930 snapshot also leads to the same result.

Configure line used for the backtrace:
CFLAGS=-O0 ./configure --disable-cgi --without-sqlite


Actual result:
--------------
(gdb) run
Starting program: /root/compile/php5-200511200930/sapi/cli/php

Program received signal SIGSEGV, Segmentation fault.
0x08200adf in _zend_hash_add_or_update ()
(gdb) bt full
#0  0x08200adf in _zend_hash_add_or_update ()
No symbol table info available.
#1  0x080ce8c4 in php_pdo_register_driver ()
No symbol table info available.
#2  0x080d8fc7 in zm_startup_pdo_sqlite ()
No symbol table info available.
#3  0x081fcd27 in zend_startup_module_ex ()
No symbol table info available.
#4  0x08202047 in zend_hash_apply ()
No symbol table info available.
#5  0x081fceb6 in zend_startup_modules ()
No symbol table info available.
#6  0x081ba3c2 in php_module_startup ()
No symbol table info available.
#7  0x082674dd in main ()
No symbol table info available.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-21 14:25 UTC] sniper@php.net
Was this really with that configure line? As I tried the same and can't get it to segfault. Do you happen to load any extensions in the used php.ini (or php-cli.ini) file?

 [2005-11-21 16:51 UTC] matteo at beccati dot com
No php.ini is present in /usr/local/lib. this was the configure line:

CFLAGS='-O0 -g' ./configure --disable-cgi --without-sqlite

which leads to the segfault on php start (I was probabily wrong saying that it was working on start).

If you need I can give you ssh access on the machine.
 [2005-11-21 17:24 UTC] sniper@php.net
Try without setting those CFLAGS. And try running PHP like this after compile:

# sapi/cli/php -n -r 'echo 1;'

Does that crash? Or this:

# sapi/cli/php -n somefile.php

 [2005-11-21 17:48 UTC] matteo at beccati dot com
Also without CFLAGS:

good-ol:~/compile/php5-200511211330# sapi/cli/php -n -r 'echo 1;'
Segmentation fault
good-ol:~/compile/php5-200511211330# sapi/cli/php -n somefile.php
Segmentation fault
 [2005-11-22 04:21 UTC] iliaa@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

Compiled with your flags and things work fine, no crashes. Even valgrind does not point to any problems...
 [2005-11-22 09:41 UTC] matteo at beccati dot com
Still segfaulting. This is the valgrind output:

good-ol:~/compile/php5-200511220530# valgrind sapi/cli/php
==12191== Memcheck, a memory error detector for x86-linux.
==12191== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
==12191== Using valgrind-2.4.0, a program supervision framework for x86-linux.
==12191== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
==12191== For more details, rerun with: -v
==12191==
==12191== Conditional jump or move depends on uninitialised value(s)
==12191==    at 0x1B8ECB13: (within /lib/ld-2.3.5.so)
==12191==    by 0x1B8E631C: (within /lib/ld-2.3.5.so)
==12191==    by 0x1B8F2BDD: (within /lib/ld-2.3.5.so)
==12191==    by 0x1B8E7675: (within /lib/ld-2.3.5.so)
==12191==    by 0x1B8E47C6: (within /lib/ld-2.3.5.so)
==12191==
==12191== Conditional jump or move depends on uninitialised value(s)
==12191==    at 0x1B8EC7D3: (within /lib/ld-2.3.5.so)
==12191==    by 0x1B8E631C: (within /lib/ld-2.3.5.so)
==12191==    by 0x1B8F2BDD: (within /lib/ld-2.3.5.so)
==12191==    by 0x1B8E7675: (within /lib/ld-2.3.5.so)
==12191==    by 0x1B8E47C6: (within /lib/ld-2.3.5.so)
==12191==
==12191== Conditional jump or move depends on uninitialised value(s)
==12191==    at 0x1B8EC6B6: (within /lib/ld-2.3.5.so)
==12191==    by 0x1B8E6376: (within /lib/ld-2.3.5.so)
==12191==    by 0x1B8F2BDD: (within /lib/ld-2.3.5.so)
==12191==    by 0x1B8E7675: (within /lib/ld-2.3.5.so)
==12191==    by 0x1B8E47C6: (within /lib/ld-2.3.5.so)
==12191==
==12191== Conditional jump or move depends on uninitialised value(s)
==12191==    at 0x1B8EC6C2: (within /lib/ld-2.3.5.so)
==12191==    by 0x1B8E6376: (within /lib/ld-2.3.5.so)
==12191==    by 0x1B8F2BDD: (within /lib/ld-2.3.5.so)
==12191==    by 0x1B8E7675: (within /lib/ld-2.3.5.so)
==12191==    by 0x1B8E47C6: (within /lib/ld-2.3.5.so)
==12191==
==12191== Conditional jump or move depends on uninitialised value(s)
==12191==    at 0x1B8EC7D3: (within /lib/ld-2.3.5.so)
==12191==    by 0x1B8E6376: (within /lib/ld-2.3.5.so)
==12191==    by 0x1B8F2BDD: (within /lib/ld-2.3.5.so)
==12191==    by 0x1B8E7675: (within /lib/ld-2.3.5.so)
==12191==    by 0x1B8E47C6: (within /lib/ld-2.3.5.so)
==12191==
==12191== Invalid read of size 4
==12191==    at 0x8200BA3: _zend_hash_add_or_update (zend_hash.c:213)
==12191==    by 0x80CE8E3: php_pdo_register_driver (pdo.c:170)
==12191==    by 0x80D8FF2: zm_startup_pdo_sqlite (pdo_sqlite.c:80)
==12191==    by 0x81FCDEA: zend_startup_module_ex (zend_API.c:1320)
==12191==    by 0x820210A: zend_hash_apply (zend_hash.c:664)
==12191==    by 0x81FCF79: zend_startup_modules (zend_API.c:1367)
==12191==    by 0x81BA459: php_module_startup (main.c:1533)
==12191==    by 0x82675A0: main (php_cli.c:655)
==12191==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==12191==
==12191== Process terminating with default action of signal 11 (SIGSEGV)
==12191==  Access not within mapped region at address 0x0
==12191==    at 0x8200BA3: _zend_hash_add_or_update (zend_hash.c:213)
==12191==    by 0x80CE8E3: php_pdo_register_driver (pdo.c:170)
==12191==    by 0x80D8FF2: zm_startup_pdo_sqlite (pdo_sqlite.c:80)
==12191==    by 0x81FCDEA: zend_startup_module_ex (zend_API.c:1320)
==12191==    by 0x820210A: zend_hash_apply (zend_hash.c:664)
==12191==    by 0x81FCF79: zend_startup_modules (zend_API.c:1367)
==12191==    by 0x81BA459: php_module_startup (main.c:1533)
==12191==    by 0x82675A0: main (php_cli.c:655)
==12191==
==12191== ERROR SUMMARY: 26 errors from 6 contexts (suppressed: 0 from 0)
==12191== malloc/free: in use at exit: 372210 bytes in 5550 blocks.
==12191== malloc/free: 5768 allocs, 218 frees, 409794 bytes allocated.
==12191== For counts of detected errors, rerun with: -v
==12191== searching for pointers to 5550 not-freed blocks.
==12191== checked 1145848 bytes.
==12191==
==12191== LEAK SUMMARY:
==12191==    definitely lost: 0 bytes in 0 blocks.
==12191==      possibly lost: 0 bytes in 0 blocks.
==12191==    still reachable: 372210 bytes in 5550 blocks.
==12191==         suppressed: 0 bytes in 0 blocks.
==12191== Reachable blocks (those to which a pointer was found) are not shown.
==12191== To see them, rerun with: --show-reachable=yes
Segmentation fault
 [2005-11-22 10:47 UTC] sniper@php.net
Since neither me or Ilia can even reproduce this, you need to give us more information:

1) What compiler are you using?
2) Can you reproduce this on some other machine?

 [2005-11-22 12:12 UTC] matteo at beccati dot com
good-ol:~/compile/php5-200511220530# gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.0 --enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre --enable-mpfr --disable-werror --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.0.2 (Debian 4.0.2-2)


I've replicated the issue on another machine:
roast:~/compile/php5-200511220930# gcc -v
Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.5/specs
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --enable-__cxa_atexit --with-system-zlib --enable-nls --without-included-gettext --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux
Thread model: posix
gcc version 3.3.5 (Debian 1:3.3.5-13)
 [2005-11-22 16:06 UTC] iliaa@php.net
I still cannot replicate the problem, what does php -m show?
 [2005-11-22 16:14 UTC] wez@php.net
The initial trace sounds like a problem with the order in which the extensions are loaded.
What does your main/internal_functions_cli.c file contain?
 [2005-11-22 16:19 UTC] matteo at beccati dot com
good-ol:~/compile/php5-200511220530# sapi/cli/php -m
Segmentation fault

This is what main/internal_functions.c contains (initial and ending comments were stripped):

/* $Id: internal_functions.c.in,v 1.30 2005/08/03 14:08:29 sniper Exp $ */

#include "php.h"
#include "php_main.h"
#include "zend_modules.h"
#include "zend_compile.h"
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>

#include "ext/libxml/php_libxml.h"
#include "ext/pcre/php_pcre.h"
#include "ext/ctype/php_ctype.h"
#include "ext/date/php_date.h"
#include "ext/dom/php_dom.h"
#include "ext/iconv/php_iconv.h"
#include "ext/pdo/php_pdo.h"
#include "ext/pdo_sqlite/php_pdo_sqlite.h"
#include "ext/posix/php_posix.h"
#include "ext/session/php_session.h"
#include "ext/simplexml/php_simplexml.h"
#include "ext/spl/php_spl.h"
#include "ext/standard/php_standard.h"
#include "ext/tokenizer/php_tokenizer.h"
#include "ext/xml/php_xml.h"


zend_module_entry *php_builtin_extensions[] = {
        phpext_xml_ptr,
        phpext_tokenizer_ptr,
        phpext_standard_ptr,
        phpext_spl_ptr,
        phpext_simplexml_ptr,
        phpext_session_ptr,
        phpext_posix_ptr,
        phpext_pdo_sqlite_ptr,
        phpext_pdo_ptr,
        phpext_iconv_ptr,
        phpext_dom_ptr,
        phpext_date_ptr,
        phpext_ctype_ptr,
        phpext_pcre_ptr,
        phpext_libxml_ptr,

};

#define EXTCOUNT (sizeof(php_builtin_extensions)/sizeof(zend_module_entry *))


int php_register_internal_extensions(TSRMLS_D)
{
        return php_register_extensions(php_builtin_extensions, EXTCOUNT TSRMLS_CC);
}
 [2005-11-23 00:40 UTC] iliaa@php.net
What version of awk are you using?
 [2005-11-23 00:49 UTC] matteo at beccati dot com
# awk -W version
mawk 1.3.3 Nov 1996, Copyright (C) Michael D. Brennan

compiled limits:
max NF             32767
sprintf buffer      1020
 [2005-11-23 00:54 UTC] matteo at beccati dot com
In fact, after installing gawk, the php_builtin_extensions array looks quite different:

zend_module_entry *php_builtin_extensions[] = {
        phpext_libxml_ptr,
        phpext_xml_ptr,
        phpext_tokenizer_ptr,
        phpext_standard_ptr,
        phpext_spl_ptr,
        phpext_simplexml_ptr,
        phpext_session_ptr,
        phpext_posix_ptr,
        phpext_pdo_ptr,
        phpext_pdo_sqlite_ptr,
        phpext_iconv_ptr,
        phpext_dom_ptr,
        phpext_date_ptr,
        phpext_ctype_ptr,
        phpext_pcre_ptr,

};
 [2005-11-23 00:55 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You are using an unsupported version on awk (please use GNU Awk) that fails to generate a proper module dependancy list.
 [2005-11-23 01:01 UTC] matteo at beccati dot com
I agree, but shouldn't configure fail in this case?
 [2005-11-23 01:08 UTC] iliaa@php.net
There is already a warning being output when mawk is used.
 [2005-11-23 08:28 UTC] matteo at beccati dot com
This is the awk related configure output:

checking for gawk... no
checking for nawk... nawk
checking if nawk is broken... no


And these are the only warnings printed to stderr:

configure: warning: You will need re2c 0.98 or later if you want to regenerate PHP parsers.
configure: warning: flex versions supported for regeneration of the Zend/PHP parsers: 2.5.4  (found: 2.5.31).
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Nov 29 01:01:25 2020 UTC