From:             davbrown4 at yahoo dot com
Operating system: Solaris
PHP version:      5.3.1
PHP Bug Type:     PDO related
Bug description:  PDO-ODBC stored procedure call from Solaris 64-bit causes seg 
fault 

Description:
------------
While testing the 64-bit version of our ODBC driver (StarQuest StarSQL
http://www.starquest.com) on Solaris SPARC, with unixODBC 2.2.14 (the
current stable version),  we encountered a seg fault when when using
PDO-ODBC to call a stored procedure.  The patch below (5.3.1) fixed our
problem.

The existing php code is making the assumption that an "enum" has the same
size as a "long". That is not the case on many 64-bit systems. We fixed
this one by using an local intermediate "long" variable. It could likely
also be fixed by modifying the format string. 
 
There may be several other faulty assumptions about the size of "enum"
that we didn't encounter.

Here are our patches to 5.3.11:


diff -ur pdo-orig/pdo_stmt.c pdo/pdo_stmt.c
--- pdo-orig/pdo_stmt.c 2009-10-19 14:43:34.000000000 -0700
+++ pdo/pdo_stmt.c      2009-12-03 16:31:18.000000000 -0800
@@ -1657,12 +1657,13 @@
 static int register_bound_param(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t
*stmt, int is_param) /* {{{ */
 {
        struct pdo_bound_param_data param = {0};
+       long param_type;

        param.paramno = -1;
        param.param_type = PDO_PARAM_STR;

        if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
ZEND_NUM_ARGS() TSRMLS_CC,
-                       "lz|llz!", &param.paramno, &param.parameter,
&param.param_type, &param.max_value_len,
+                       "lz|llz!", &param.paramno, &param.parameter,
&param_type, &param.max_value_len,
                        &param.driver_params)) {
                if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS()
TSRMLS_CC, "sz|llz!", &param.name,
                                &param.namelen, &param.parameter,
&param.param_type, &param.max_value_len,
@@ -1671,6 +1672,7 @@
                }
        }

+       param.param_type = (int)param_type;
        if (param.paramno > 0) {
                --param.paramno; /* make it zero-based internally */
        } else if (!param.name) {




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

// Connect to the database
try{
$dbh = new PDO("odbc:MAX64", 'USER', 'PWD');
}catch (PDOException $e) {
    print "Error!: " . $e->getMessage();
    die();
}

// Set parameter values
$inval = 'ANNIE';
$inoutval = 'HALL';
$outval = NULL;

// Prepare stored procedure call with three parameters
$sth = $dbh->prepare('CALL USER.SPROC(?, ?, ?)');

// Bind parameter 1 as IN parameter
// Be sure *not* to set a length to indicate it's an IN parameter
$sth->bindParam(1, $inval, PDO::PARAM_STR);

// Bind parameter 2 as INOUT parameter
$sth->bindParam(2, $inoutval, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT,
20);

// Bind parameter 3 as OUT parameter
// Be sure to explicitly set a length to indicate it's an OUTPUT
parameter
$sth->bindParam(3, $outval, PDO::PARAM_INT, 20);

// Call the stored procedure
print "Executing stored procedure...\n";
$res = $sth->execute();
....




-- 
Edit bug report at http://bugs.php.net/?id=50445&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=50445&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=50445&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=50445&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=50445&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=50445&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=50445&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=50445&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=50445&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=50445&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=50445&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=50445&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=50445&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=50445&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=50445&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=50445&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=50445&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=50445&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=50445&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=50445&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=50445&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=50445&r=mysqlcfg

Reply via email to