Bug #20515 php segmentation fault using unixODBC and mysql-connector-odbc-3.51.12-1
Submitted: 16 Jun 2006 18:08 Modified: 30 May 2013 7:17
Reporter: Robert Toole Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:3.51 OS:Linux (CentOS 4)
Assigned to: CPU Architecture:Any

[16 Jun 2006 18:08] Robert Toole
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...
[16 Jun 2006 18:10] Robert Toole
php.ini

Attachment: php.ini (application/octet-stream, text), 4.44 KiB.

[28 Jun 2006 9:03] Sveta Smirnova
Thank you for the report.

I can't repeat it on Linux and Solaris using php5.2 If "No problems connecting using isql" is a little chance what is our bug.
[19 Nov 2007 22:24] erik aronesty
This is failing for me as well, running mysql-connector-odbc-3.51.22-0 on Centos 4.4 (kernel 2.6.9-55.0.12.EL)

No need to run php, any apache module (python, etc.) seems to fail, whereas command-line programs (php-cli, python) can connect fine

(Centos 5 also fails)
[20 Nov 2007 10:29] Susanne Ebrecht
Many thanks for testing with the newest version.
Please, could you add a little test file and a trace file about the failure.
For creating a tracefile, add the following at your .odbc.ini:

[ODBC]
Trace=1
TraceFile=/home/myhome/mysql.myodbc3.$t.trace

the "mysql.myodbc3.$1.trace" is the filename, you can choose here, whatever you want. The "$t" provides the time in your file name.

Also it would be interesting for us, if your problem occurs in MyODBC 5.1 too.
[21 Dec 2007 0:00] Bugs System
No feedback was provided for this bug for over a month, 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".
[30 May 2013 7:17] Bogdan Degtyariov
I'm closing this bug because I can not continue without feedback from the reporter. If you have new info, please reopen the report.