|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-05-15 10:01 UTC] dhrubab at gmail dot com
Description: ------------ The provided code causes a segfault. My php.ini settings are as below. short_open_tag = Off allow_call_time_pass_reference = Off error_reporting = E_ALL display_errors = On display_startup_errors = On log_errors = Off variables_order = "GPCS" register_globals = Off register_long_arrays = Off register_argc_argv = Off magic_quotes_gpc = Off magic_quotes_runtime = Off allow_url_fopen = On session.name = GRTSESSID session.use_trans_sid = 0 session.hash_function = 1 session.hash_bits_per_character = 5 My configure is as below. './configure' '--prefix=/usr/lib/php5' '--sysconfdir=/etc' '--cache-file=./config.cache' '--disable-cli' '--with-apxs2=/usr/sbin/apxs2' '--with-config-file-path=/etc/php/apache2-php5' '--with-config-file-scan-dir=/etc/php/apache2-php5/ext-active' '--without-pear' '--disable-bcmath' '--with-bz2=shared' '--enable-calendar=shared' '--with-curl=shared' '--with-curlwrappers=shared' '--disable-dbase' '--enable-exif=shared' '--without-fbsql' '--without-fdftk' '--disable-filepro' '--enable-ftp=shared' '--with-gettext=shared' '--without-gmp' '--without-hwapi' '--without-informix' '--disable-ipv6' '--without-kerberos' '--enable-mbstring=shared' '--with-mcrypt=shared' '--disable-memory-limit' '--with-mhash=shared' '--without-ming' '--without-msql' '--without-mssql' '--with-ncurses=shared' '--with-openssl' '--with-openssl-dir=/usr' '--enable-pcntl=shared' '--disable-pdo' '--without-pgsql' '--with-pspell=shared' '--without-recode' '--disable-shmop' '--without-snmp' '--enable-soap=shared' '--enable-sockets=shared' '--without-sybase' '--without-sybase-ct' '--disable-sysvmsg' '--disable-sysvsem' '--disable-sysvshm' '--with-tidy=shared' '--enable-wddx=shared' '--with-xmlrpc=shared' '--with-xsl=shared' '--with-zlib=shared' '--enable-debug' '--without-cdb' '--without-db4' '--without-flatfile' '--without-gdbm' '--without-inifile' '--without-qdbm' '--with-freetype-dir=/usr' '--with-t1lib=/usr' '--disable-gd-jis-conv' '--enable-gd-native-ttf' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--without-xpm-dir' '--with-gd' '--with-imap=shared' '--with-imap-ssl' '--with-mysql=shared,/usr/lib/mysql' '--with-mysql-sock=/var/run/mysqld/mysqld.sock' '--with-mysqli=shared,/usr/bin/mysql_config' '--with-readline' '--without-libedit' '--without-mm' '--enable-sqlite-utf8' My full phpinfo() is below. http://www.dhruba.net/files/segfault.phpinfo.html This is simply one example of a segfault. Our application is segfaulting left, right and centre and I am trying to narrow down other test cases that result in segfaults. The main point is that PHP or PDO whichever is the culprit is not giving error messages or exceptions as it should when there's something wrong and instead segfaulting. When you use a method name that doesn't exist or a class constant that doesn't exist or when you violate allow_call_time_pass_reference = Off then a segfault occurs. This has been reproduced on three machines with three different linux distributions. Reproduce code: --------------- The source code is below. http://www.dhruba.net/files/segfault.php Expected result: ---------------- It should give me an error about passing a string by reference in bindParam(). Actual result: -------------- It segfaults. Backtrace is below. sepoy ~ # gdb /usr/sbin/apache2 GNU gdb 6.4 Copyright 2005 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "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 -X -D DEFAULT_VHOST -D PHP5 -D INFO -D USERDIR -d /usr/lib/apache2 -f /etc/apache2/httpd.conf -k start Starting program: /usr/sbin/apache2 -X -D DEFAULT_VHOST -D PHP5 -D INFO -D USERDIR -d /usr/lib/apache2 -f /etc/apache2/httpd.conf -k start [Thread debugging using libthread_db enabled] [New Thread 16384 (LWP 4165)] [Mon May 15 10:40:27 2006] [warn] NameVirtualHost *:80 has no VirtualHosts Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 16384 (LWP 4165)] 0xb6e1025d in mysql_more_results () from /usr/lib/libmysqlclient.so.15 (gdb) bt #0 0xb6e1025d in mysql_more_results () from /usr/lib/libmysqlclient.so.15 #1 0xb6ddb9b9 in free_statement (stmt=0x82c10cc) at /var/tmp/portage/pecl-pdo-1.0.3/work/PDO-1.0.3/pdo_stmt.c:2200 #2 0xb6ddbb6c in php_pdo_stmt_delref (stmt=0x5a5a5a5a) at /var/tmp/portage/pecl-pdo-1.0.3/work/PDO-1.0.3/pdo_stmt.c:2239 #3 0xb6ddbb8b in pdo_dbstmt_free_storage (stmt=0x5a5a5a5a) at /var/tmp/portage/pecl-pdo-1.0.3/work/PDO-1.0.3/pdo_stmt.c:2245 #4 0xb78eae78 in zend_objects_store_free_object_storage (objects=0xb7a65bac) at /var/tmp/portage/php-5.1.4/work/php-5.1.4/Zend/zend_objects_API.c:86 #5 0xb78c0501 in shutdown_executor () at /var/tmp/portage/php-5.1.4/work/php-5.1.4/Zend/zend_execute_API.c:281 #6 0xb78ce7a2 in zend_deactivate () at /var/tmp/portage/php-5.1.4/work/php-5.1.4/Zend/zend.c:854 #7 0xb788a816 in php_request_shutdown (dummy=0x0) at /var/tmp/portage/php-5.1.4/work/php-5.1.4/main/main.c:1287 #8 0xb796e64c in php_apache_request_dtor (r=0x82aecd8) at /var/tmp/portage/php-5.1.4/work/php-5.1.4/sapi/apache2handler/sapi_apache2.c:445 #9 0xb796ecad in php_handler (r=0x82aecd8) at /var/tmp/portage/php-5.1.4/work/php-5.1.4/sapi/apache2handler/sapi_apache2.c:603 #10 0x08068ed5 in ap_run_handler (r=0x82aecd8) at config.c:152 #11 0x0806941f in ap_invoke_handler (r=0x82aecd8) at config.c:364 #12 0x08065ea7 in ap_process_request (r=0x82aecd8) at http_request.c:249 #13 0x08060dbc in ap_process_http_connection (c=0x82a8b30) at http_core.c:251 #14 0x08072e59 in ap_run_process_connection (c=0x82a8b30) at connection.c:43 #15 0x0807316e in ap_process_connection (c=0x82a8b30, csd=0x5a5a5a5a) at connection.c:176 #16 0x08067666 in child_main (child_num_arg=1515870810) at prefork.c:610 #17 0x08067746 in make_child (s=0x82c10cc, slot=0) at prefork.c:650 #18 0x08067880 in startup_children (number_to_start=5) at prefork.c:722 #19 0x08067caf in ap_mpm_run (_pconf=0x80a1e58, plog=0x80cdf08, s=0x5) at prefork.c:941 #20 0x0806e986 in main (argc=16, argv=0xbfc52894) at main.c:618 (gdb) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 13:00:02 2025 UTC |
$oDB= new PDO('mysql:host=localhost;dbname=yourdb', 'user', 'pass'); // emulated or not does not matter $oDB->setAttribute(PDO :: ATTR_EMULATE_PREPARES, true); $oStm = $oDB->prepare("SELECT * FROM tbl WHERE xyz=:character_set"); $oStm->bindParam(':character_set', 'foo); For the record, the problem here is only about how PDO manages to free its resource when a fatal error or exit() occurs. In this example, it is a fatal error raise with the bindParam call (it expects a variable as it uses a reference). The problem is the same in many other bug reports (unexpected script exist, like exit() in a function). The solution is to always set query_stmt in the dbh struct, and add another flag to define if there was an error or not. I have patches that fix the problem for mysql. To be sure I don't break something in the working drivers, I have to install pgsql.