php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42242 sybase_connect() crashes
Submitted: 2007-08-08 08:46 UTC Modified: 2007-08-10 00:43 UTC
Votes:2
Avg. Score:4.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: roberto dot valsania at mail dot wind dot it Assigned:
Status: Closed Package: Sybase (dblib) related
PHP Version: 5CVS-2007-08-08 (snap) OS: FEDORA 7
Private report: No CVE-ID:
 [2007-08-08 08:46 UTC] roberto dot valsania at mail dot wind dot it
Description:
------------
php segmentation fault when try connect to sybase database


PHP Version:
[root@dba-iv1 cli]# php -v
PHP 5.2.3 (cli) (built: Aug  8 2007 09:49:36) 
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
[root@dba-iv1 cli]# 

Configure Option :
./configure --with-sybase=$SYBASE/OCS-15_0 --enable-debug

Reproduce code:
---------------
<?php

$db = sybase_connect("DBA_SUN_TEST","sa","dba_sun_test")  ;
print sybase_get_last_message () ;
sybase_close($db);

?>


Expected result:
----------------
Connect and disconect to Sybase DB



Actual result:
--------------
segmentation fault 
Here the stacktrace :

[root@dba-iv1 cli]# gdb php
GNU gdb Red Hat Linux (6.6-15.fc7rh)
Copyright (C) 2006 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 "i386-redhat-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) run /root/test_sybase.php
Starting program: /root/Development/php-5.2.3_Develop_valsa/php-5.2.3/sapi/cli/php /root/test_sybase.php
[Thread debugging using libthread_db enabled]
[New Thread -1208444720 (LWP 13659)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208444720 (LWP 13659)]
zend_hash_find (ht=0x83afa00, 
    arKey=0x8be2e5c "sybase_DBA_SUN_TEST_sa_dba_sun_test__", 
    nKeyLength=146298445, pData=0xbfc69420)
    at /root/Development/php-5.2.3_Develop_valsa/php-5.2.3/Zend/zend_hash.h:264
264                     hash = ((hash << 5) + hash) + *arKey++;
(gdb) bt
#0  zend_hash_find (ht=0x83afa00, 
    arKey=0x8be2e5c "sybase_DBA_SUN_TEST_sa_dba_sun_test__", 
    nKeyLength=146298445, pData=0xbfc69420)
    at /root/Development/php-5.2.3_Develop_valsa/php-5.2.3/Zend/zend_hash.h:264
#1  0x0821a60b in php_sybase_do_connect (ht=<value optimized out>, 
    return_value=0x8be2e44, return_value_ptr=<value optimized out>, 
    this_ptr=0x0, return_value_used=1, persistent=0)
    at /root/Development/php-5.2.3_Develop_valsa/php-5.2.3/ext/sybase/php_sybase_db.c:495
#2  0x08292738 in zend_do_fcall_common_helper_SPEC (execute_data=0xbfc695b0)
    at /root/Development/php-5.2.3_Develop_valsa/php-5.2.3/Zend/zend_vm_execute.h:200
#3  0x08283f4d in execute (op_array=0x8be28d0)
    at /root/Development/php-5.2.3_Develop_valsa/php-5.2.3/Zend/zend_vm_execute.h:92
#4  0x08266cf2 in zend_execute_scripts (type=8, retval=<value optimized out>, 
    file_count=3)
    at /root/Development/php-5.2.3_Develop_valsa/php-5.2.3/Zend/zend.c:1134
#5  0x08227d63 in php_execute_script (primary_file=0xbfc6b96c)
    at /root/Development/php-5.2.3_Develop_valsa/php-5.2.3/main/main.c:1794
#6  0x082df307 in main (argc=2, argv=0xbfc6ba84)
    at /root/Development/php-5.2.3_Develop_valsa/php-5.2.3/sapi/cli/php_cli.c:1138
(gdb) 

Please Note : Compile with freetds and mssql the connect is ok

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-08 08:57 UTC] roberto dot valsania at mail dot wind dot it
The same crash and stacktrace with PHP compiled from official srpms fedora 7 update (PHP 5.2.2 (cli) (built: May  8 2007 08:15:05))
 [2007-08-08 09:02 UTC] jani@php.net
Have you tried using the sybase-ct extension instead?
 [2007-08-08 09:31 UTC] roberto dot valsania at mail dot wind dot it
Yes , but it does not link .
Here the last lines ..

zend_exceptions.o Zend/zend_strtod.o Zend/zend_objects.o Zend/zend_object_handle                                            rs.o Zend/zend_objects_API.o Zend/zend_default_classes.o Zend/zend_execute.o sap                                            i/cgi/cgi_main.o sapi/cgi/getopt.o main/internal_functions.o -o sapi/cgi/php-cgi                                             -Wl,--export-dynamic  -L/sbrdbms/sybase/OpenClient15//OCS-15_0/lib -lcrypt -lsy                                            btcl -lintl -lcomn -lct -lcs -lcrypt -lrt -lresolv -lm -ldl -lnsl -lxml2 -lz -lm                                             -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz                                             -lm -lcrypt -Wl,--rpath -Wl,/sbrdbms/sybase/OpenClient15//OCS-15_0/lib
/usr/bin/ld: cannot find -lintl
collect2: ld returned 1 exit status
make: *** [sapi/cgi/php-cgi] Error 1
[root@dba-iv1 php-5.2.3]#
 [2007-08-08 10:21 UTC] roberto dot valsania at mail dot wind dot it
I was able to compile with --with-sybase-ct and it seems to works

Here a short description of the tests that i made :

1) Compile with "--with-sybase=.." and Sybase OpenClient 15.
This cause php to crash ( php 5.2.2 php 5.2.3 )

2) Impossible to compile with "--with-sybase-ct=..." and Sybase OpenClient15.
The reason is that with OpenClient15 the library "libintl" is renamed in "libsybintl"

3) OK to compile and execute test code with "--with-sybase-ct=.." and Sybase OpenClient 12.5
 [2007-08-10 00:43 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 02:02:27 2014 UTC