Description:
When using php5 + unixODBC + mySQL, php segfaults on odbc_exec.
No problems connecting using isql
even if my php code is wrong... it should not segfault?
Is this a php, unixODBC, MySQL, RHEL or CentOS bug?
The segfault only occurs once a sucessful connection is made, (If you use the wrong password, etc, php displays the expected error messages)
The following backtrace was obtained running a simple php script (see how to repeat) from the command line to eliminate apache as a possible source of the problem.
selinux is completely disabled (selinux=0) in grub.conf
Backtrace:
(no debugging symbols found)
1.2.
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208849696 (LWP 3198)]
0x00698d96 in my_SQLPrepare (hstmt=0x8521458, szSqlStr=0x0, cbSqlStr=0) at prepare.c:97
97 prepare.c: No such file or directory.
in prepare.c
(gdb) bt
0 0x00698d96 in my_SQLPrepare (hstmt=0x8521458, szSqlStr=0x0, cbSqlStr=0) at prepare.c:97
0000001 0x00695720 in SQLExecDirect (hstmt=0x8521458, szSqlStr=0x0, cbSqlStr=0) at execute.c:666
0000002 0x0059ac02 in SQLExecDirect () from /usr/lib/libodbc.so.1
3 0x0057cb07 in zif_odbc_exec () from /usr/lib/php/modules/odbc.so
4 0x081a6e70 in zend_do_fcall_common_helper ()
5 0x081a70e0 in zend_do_fcall_handler ()
6 0x08197451 in execute ()
0000007 0x08176e39 in zend_execute_scripts ()
0000008 0x08140732 in php_execute_script ()
0000009 0x00000000 in ?? ()
(gdb) quit
I am using the following packages:
rpm -qa | grep mysql
mysql-connector-odbc-3.51.12-1
php-mysql-5.0.4-5.centos4
mod_auth_mysql-2.6.1-2.2
libdbi-dbd-mysql-0.6.5-10.RHEL4.1
mysqlclient10-3.23.58-4.RHEL4.1
mysql-bench-4.1.20-1.RHEL4.1
rpm -qa | grep MySQL
MySQL-shared-compat-5.0.22-0.rhel4
MySQL-client-standard-5.0.22-0.rhel4
qt-MySQL-3.3.3-9.3
MySQL-devel-standard-5.0.22-0.rhel4
MySQL-python-1.0.0-1.RHEL4.1
MySQL-server-standard-5.0.22-0.rhel4
perl-DBD-MySQL-2.9004-3.1
MySQL-standard-debuginfo-5.0.22-0.rhel4
rpm -qa | grep php
php-mssql-5.0.4-10.1
php-mysql-5.0.4-5.centos4
php-5.0.4-5.centos4
php-odbc-5.0.4-5.centos4
php-ldap-5.0.4-5.centos4
php-pear-5.0.4-5.centos4
unixODBC-2.2.11-1.RHEL4.1
-- my.cnf: --
[client]
port = 3306
socket = /var/lib/mysql/mysql.sock
[mysqld]
default-table-type=innodb
old_passwords=1
port = 3306
socket = /var/lib/mysql/mysql.sock
skip-locking
key_buffer = 256M
max_allowed_packet = 1M
table_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
thread_concurrency = 8
log-bin=mysql-bin
server-id = 1
innodb_data_home_dir = /var/lib/mysql/
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /var/lib/mysql/
innodb_log_arch_dir = /var/lib/mysql/
innodb_buffer_pool_size = 256M
innodb_additional_mem_pool_size = 20M
innodb_log_file_size = 64M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[isamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
[myisamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
-- odbc.ini: --
[ODBC]
TraceFile = /tmp/odbc.trace
Trace = 1
DebugFile = /tmp/odbc.debug
Debug = 1
[ODBC-Portmapper]
Description = Cabinet 01 Port Map
Trace = On
TraceFile = stderr
Driver = MySQL
SERVER = localhost
USER = username
PASSWORD = password
PORT = 3306
DATABASE = Portmapper
-- odbcinst.ini: --
[PostgreSQL]
Description = ODBC for PostgreSQL
Driver = /usr/lib/libodbcpsql.so
Setup = /usr/lib/libodbcpsqlS.so
FileUsage = 1
[MySQL]
DRIVER = /usr/lib/libmyodbc3.so
SETUP = /usr/lib/libmyodbc3S.so
UsageCount = 1
How to repeat:
Install CentOS 4, install the above listed packages (php 5.0 from the centosplus repository)
Run the following php script from the command line:
<?php
$connect = odbc_connect("ODBC-Portmapper", "username", "password");
print "1 ";
$unitquery = "Select * from tblportlist WHERE datadrop LIKE 01-01C";
print "2 ";
$unitresult = odbc_exec($connect, $unitquery) or die ("Query Failed.");
print "3 ";
print "$unitresult";
?>
Thank-you in advance...
Description: When using php5 + unixODBC + mySQL, php segfaults on odbc_exec. No problems connecting using isql even if my php code is wrong... it should not segfault? Is this a php, unixODBC, MySQL, RHEL or CentOS bug? The segfault only occurs once a sucessful connection is made, (If you use the wrong password, etc, php displays the expected error messages) The following backtrace was obtained running a simple php script (see how to repeat) from the command line to eliminate apache as a possible source of the problem. selinux is completely disabled (selinux=0) in grub.conf Backtrace: (no debugging symbols found) 1.2. Program received signal SIGSEGV, Segmentation fault. [Switching to Thread -1208849696 (LWP 3198)] 0x00698d96 in my_SQLPrepare (hstmt=0x8521458, szSqlStr=0x0, cbSqlStr=0) at prepare.c:97 97 prepare.c: No such file or directory. in prepare.c (gdb) bt 0 0x00698d96 in my_SQLPrepare (hstmt=0x8521458, szSqlStr=0x0, cbSqlStr=0) at prepare.c:97 0000001 0x00695720 in SQLExecDirect (hstmt=0x8521458, szSqlStr=0x0, cbSqlStr=0) at execute.c:666 0000002 0x0059ac02 in SQLExecDirect () from /usr/lib/libodbc.so.1 3 0x0057cb07 in zif_odbc_exec () from /usr/lib/php/modules/odbc.so 4 0x081a6e70 in zend_do_fcall_common_helper () 5 0x081a70e0 in zend_do_fcall_handler () 6 0x08197451 in execute () 0000007 0x08176e39 in zend_execute_scripts () 0000008 0x08140732 in php_execute_script () 0000009 0x00000000 in ?? () (gdb) quit I am using the following packages: rpm -qa | grep mysql mysql-connector-odbc-3.51.12-1 php-mysql-5.0.4-5.centos4 mod_auth_mysql-2.6.1-2.2 libdbi-dbd-mysql-0.6.5-10.RHEL4.1 mysqlclient10-3.23.58-4.RHEL4.1 mysql-bench-4.1.20-1.RHEL4.1 rpm -qa | grep MySQL MySQL-shared-compat-5.0.22-0.rhel4 MySQL-client-standard-5.0.22-0.rhel4 qt-MySQL-3.3.3-9.3 MySQL-devel-standard-5.0.22-0.rhel4 MySQL-python-1.0.0-1.RHEL4.1 MySQL-server-standard-5.0.22-0.rhel4 perl-DBD-MySQL-2.9004-3.1 MySQL-standard-debuginfo-5.0.22-0.rhel4 rpm -qa | grep php php-mssql-5.0.4-10.1 php-mysql-5.0.4-5.centos4 php-5.0.4-5.centos4 php-odbc-5.0.4-5.centos4 php-ldap-5.0.4-5.centos4 php-pear-5.0.4-5.centos4 unixODBC-2.2.11-1.RHEL4.1 -- my.cnf: -- [client] port = 3306 socket = /var/lib/mysql/mysql.sock [mysqld] default-table-type=innodb old_passwords=1 port = 3306 socket = /var/lib/mysql/mysql.sock skip-locking key_buffer = 256M max_allowed_packet = 1M table_cache = 256 sort_buffer_size = 1M read_buffer_size = 1M read_rnd_buffer_size = 4M myisam_sort_buffer_size = 64M thread_cache_size = 8 query_cache_size= 16M thread_concurrency = 8 log-bin=mysql-bin server-id = 1 innodb_data_home_dir = /var/lib/mysql/ innodb_data_file_path = ibdata1:10M:autoextend innodb_log_group_home_dir = /var/lib/mysql/ innodb_log_arch_dir = /var/lib/mysql/ innodb_buffer_pool_size = 256M innodb_additional_mem_pool_size = 20M innodb_log_file_size = 64M innodb_log_buffer_size = 8M innodb_flush_log_at_trx_commit = 1 innodb_lock_wait_timeout = 50 [mysqldump] quick max_allowed_packet = 16M [mysql] no-auto-rehash [isamchk] key_buffer = 128M sort_buffer_size = 128M read_buffer = 2M write_buffer = 2M [myisamchk] key_buffer = 128M sort_buffer_size = 128M read_buffer = 2M write_buffer = 2M [mysqlhotcopy] interactive-timeout [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid -- odbc.ini: -- [ODBC] TraceFile = /tmp/odbc.trace Trace = 1 DebugFile = /tmp/odbc.debug Debug = 1 [ODBC-Portmapper] Description = Cabinet 01 Port Map Trace = On TraceFile = stderr Driver = MySQL SERVER = localhost USER = username PASSWORD = password PORT = 3306 DATABASE = Portmapper -- odbcinst.ini: -- [PostgreSQL] Description = ODBC for PostgreSQL Driver = /usr/lib/libodbcpsql.so Setup = /usr/lib/libodbcpsqlS.so FileUsage = 1 [MySQL] DRIVER = /usr/lib/libmyodbc3.so SETUP = /usr/lib/libmyodbc3S.so UsageCount = 1 How to repeat: Install CentOS 4, install the above listed packages (php 5.0 from the centosplus repository) Run the following php script from the command line: <?php $connect = odbc_connect("ODBC-Portmapper", "username", "password"); print "1 "; $unitquery = "Select * from tblportlist WHERE datadrop LIKE 01-01C"; print "2 "; $unitresult = odbc_exec($connect, $unitquery) or die ("Query Failed."); print "3 "; print "$unitresult"; ?> Thank-you in advance...