|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10879 odbc_prepare causes bus error
Submitted: 2001-05-15 10:25 UTC Modified: 2001-06-21 11:17 UTC
From: ville dot alkkiomaki at sonera dot com Assigned:
Status: Closed Package: ODBC related
PHP Version: 4.0.5 OS: Solaris 6/7/8
Private report: No CVE-ID: None
 [2001-05-15 10:25 UTC] ville dot alkkiomaki at sonera dot com
Following script causes Bus error with php 4.0.5 & Solid 3.x (and at least 4.0.3 & 4.0.1pl2). It crashes identically as a standalone cgi binary and as a apache module.

if($hdbc=odbc_connect("tcp localhost 1313","login", "password")) {
  if($hstmt=odbc_prepare($hdbc, "SELECT * FROM FX_USER WHERE LOGIN=?")) {
      if(odbc_execute($hstmt,array("user"))) {
        print("OK -- query completed with success\n");
} else print("Connect to database failed.\n");

Where odbc_prepare causes Bus error and gdb gives following backtrace when configured with "--with-solid --enable-debug".

#0  0xef6c7bb4 in ssa_stmt_getstmtintegerproperty ()
   from /usr/lib/
#1  0xef6c4070 in SSAGetIntegerProperty () from /usr/lib/
#2  0xef6aabb4 in SQLNumParams_nomutex () from /usr/lib/
#3  0xef6aac74 in SQLNumParams () from /usr/lib/
#4  0x32bc8 in php_if_odbc_prepare (ht=2, return_value=0x1d1080, this_ptr=0x0, 
    return_value_used=1) at php_odbc.c:812
#5  0x14acd8 in execute ()
#6  0xef07c in zend_execute_scripts (type=8, file_count=3) at zend.c:743
#7  0x27880 in php_execute_script (primary_file=0xeffffbc8) at main.c:1209
#8  0x24424 in main (argc=2, argv=0xeffffc6c) at cgi_main.c:730

Above script works fine with php 3.0.18RC1 & Solid 3.0 SDK. Older php3 releases had problems to compile with Solid 3.x, but if I recall right php version 3.0.1* had also similar problems. (required little hacking to compile) 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-29 22:45 UTC]
Before we continue down this path please ensure you have the
latest libraries from SolidTech. A bunch were distributed
and did not contain any of the important parts built in. 
Contact solidtech support for more information (they are not
available on the Web site).

Once you're sure of this and it still happens... tell us more!
 [2001-05-31 02:30 UTC] ville dot alkkiomaki at sonera dot com
Solidtech support have been contacted and they have provided new libraries for us (3.51.0154). Unfortunately this does not fix the problem.

I also tried this with Solaris 7/Forte 6 compiler/php 4.0.5/solid SDK 3.51.0154 combination. Result is the same.

After some debugging & core dumping I found out that casting odbc_result->numparams to long (instead of SWORD) fixes these problems. (line 270 on ext/odbc/php_odbc.h)

According to the odbc specifications, second parameter for SQLNumParams() should be SQLSMALLINT. This is redefined as SWORD within the php_odbc.h (I wonder why), but removing this define does not fix the problem. It seems that even when Solid gets correct sized parameters it still writes beyond them and thus cause these bus errors.

 [2001-05-31 06:38 UTC] ville dot alkkiomaki at sonera dot com
Got little further, now commit is causing segmentation faults.. :) However changing line 2423 from ext/odbc/php_odbc.c 


        if ((*pv_onoff)) {
        if (pv_onoff && (*pv_onoff)) {

#if !defined(HAVE_DBMAKER) && !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) &&!defined(HAVE_SOLID_35)
        if ((*pv_onoff)) {
        if (pv_onoff && (*pv_onoff)) {

..seems to fix problems this time...
 [2001-05-31 11:45 UTC]
actually the change in the source (which I thought made it into 4.0.5) was:


        #ifndef HAVE_DBMAKER
                if ((*pv_onoff)) {
        	if (pv_onoff && (*pv_onoff)) {

	if (pv_onoff && (*pv_onoff)) {

the SQLSMALLINT and the SWORD are defined to be the same in Solid 3.5 (both are short ints).
 [2001-06-04 06:39 UTC] ville dot alkkiomaki at sonera dot com
Well.. using short int as a parameter for SQLNumParams() causes bus error and using int (or long) does not. Include files supplied with the Solid SDK also defines that this parameter should be short int, but the library itself seems to handle it as an int. Have I missed something or is this Solid's bug.. (?!) 

Anyway, with these two workarounds the Apache 1.3.19/mod_ssl 2.8.3/OpenSSL 0.9.6a/PHP 4.0.5/Solid SDK 3.50 combination seems to work correctly..

 [2001-06-21 11:17 UTC]
that would be a bug in Solid I believe (re: short int).  you might wish to contact them and inquire about it.  

marking this as closed as it follows the ODBC spec.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Sep 28 05:01:24 2023 UTC