From:             [EMAIL PROTECTED]
Operating system: Mac OS X 10.4
PHP version:      5CVS-2005-10-07 (snap)
PHP Bug Type:     PDO related
Bug description:  (DBLIB) Calling PDO::errorInfo causes SIGSEGV if no errors 
have occured

Description:
------------
Calling the PDO:errorInfo() after successful query execution might seem a
little useless but it really shouldn't crash the process.

I tracked down the problem with valgrind (on a debian box) and I'm pasting
the partial output here:

==2622== Process terminating with default action of signal 11 (SIGSEGV)
==2622==  Access not within mapped region at address 0x0
==2622==    at 0x1B9057F8: strlen (mac_replace_strmem.c:189)
==2622==    by 0x82A11DA: add_next_index_string (zend_API.c:1040)
==2622==    by 0x81556A3: dblib_fetch_error (dblib_driver.c:64)
==2622==    by 0x82C1FB5: zend_do_fcall_common_helper_SPEC
(zend_vm_execute.h:184)
==2622==    by 0x82C17D8: execute (zend_vm_execute.h:87)
==2622==    by 0x82A02CB: zend_execute_scripts (zend.c:1078)
==2622==    by 0x82689BA: php_execute_script (main.c:1672)
==2622==    by 0x83291C9: main (php_cli.c:1039)

I'm not very good with C but I was able to alter the behavior to be the
same (I believe) as with PgSQL driver with the following patch:

--- dblib_driver.c.old  2005-10-07 11:45:24.000000000 +0300
+++ dblib_driver.c      2005-10-07 11:23:04.000000000 +0300
@@ -54,6 +54,10 @@
                msg = einfo->dberrstr;
        }
 
+       if (einfo->dberr == 0) {
+               return 1;
+       }
+
        spprintf(&message, 0, "%s [%d] (severity %d) [%s]",
                msg, einfo->dberr, einfo->severity, stmt ?
stmt->active_query_string : "");
 


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

$pdo = new PDO(...);
var_dump($pdo->errorInfo());

?>

Expected result:
----------------
array(1) {
  [0]=>
  string(0) ""
}

Actual result:
--------------
zsh: bus error  /usr/local/bin/php dblib.php


-- 
Edit bug report at http://bugs.php.net/?id=34777&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=34777&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=34777&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=34777&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=34777&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=34777&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=34777&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=34777&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=34777&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=34777&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=34777&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=34777&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=34777&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=34777&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=34777&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=34777&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=34777&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=34777&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=34777&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=34777&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=34777&r=mysqlcfg

Reply via email to