Bug #66033 [NEW]: Segmentation Fault when constructor of PDO statement throws an exception

From: Date: Mon, 04 Nov 2013 21:50:09 +0000
Subject: Bug #66033 [NEW]: Segmentation Fault when constructor of PDO statement throws an exception
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-182596@lists.php.net to get a copy of this message
From:             cbrichford+phpbugs at appdynamics dot com
Operating system: CentOS 5.5
PHP version:      Irrelevant
Package:          PDO related
Bug Type:         Bug
Bug description:Segmentation Fault when constructor of PDO statement throws an exception

Description:
------------
On PHP 5.5.4 and PHP 5.3.27, the test script in this bug segfaults.

Test script:
---------------
<pre>
<?php
class DBStatement extends PDOStatement {
    public $dbh;
    protected function __construct($dbh) {
        $this->dbh = $dbh;
        throw new Exception("Blah");
    }
}

$pdo = new PDO('sqlite::memory:', null, null);
$pdo->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('DBStatement',
array($pdo)));
$pdo->exec("CREATE TABLE IF NOT EXISTS messages (
                    id INTEGER PRIMARY KEY,
                    title TEXT,
                    message TEXT,
                    time INTEGER)");

$pdoStatement = $pdo->query("select * from messages");
var_dump($pdoStatement);
?>

Expected result:
----------------
Print out of the pdoStatement variable.

Actual result:
--------------
<pre>

Program received signal SIGSEGV, Segmentation fault.
_zval_ptr_dtor (zval_ptr=0x7fffffffad40) at
/home/cbrichford/git/github/php-src/Zend/zend_execute_API.c:426
426		i_zval_ptr_dtor(*zval_ptr ZEND_FILE_LINE_RELAY_CC);
(gdb) where
#0  _zval_ptr_dtor (zval_ptr=0x7fffffffad40) at
/home/cbrichford/git/github/php-src/Zend/zend_execute_API.c:426
#1  0x000000000053e97f in pdo_stmt_construct (stmt=<value optimized
out>, object=0x2aaaaaafabe0, dbstmt_ce=0x2aaaaaafaf68, ctor_args=<value
optimized out>)
    at /home/cbrichford/git/github/php-src/ext/pdo/pdo_dbh.c:499
#2  0x00000000005405d8 in zim_PDO_query (ht=1,
return_value=0x2aaaaaafabe0, return_value_ptr=0x0,
this_ptr=0x2aaaaaaf9010, return_value_used=1)
    at /home/cbrichford/git/github/php-src/ext/pdo/pdo_dbh.c:1143
#3  0x0000000000713b73 in zend_do_fcall_common_helper_SPEC
(execute_data=<value optimized out>) at
/home/cbrichford/git/github/php-src/Zend/zend_vm_execute.h:550
#4  0x0000000000705080 in execute_ex (execute_data=0x2aaaaaac6280) at
/home/cbrichford/git/github/php-src/Zend/zend_vm_execute.h:363
#5  0x0000000000691589 in zend_execute_scripts (type=8, retval=0x0,
file_count=3) at /home/cbrichford/git/github/php-src/Zend/zend.c:1318
#6  0x00000000006332a9 in php_execute_script
(primary_file=0x7fffffffe450) at
/home/cbrichford/git/github/php-src/main/main.c:2489
#7  0x0000000000741a9c in do_cli (argc=2, argv=0xd9e900) at
/home/cbrichford/git/github/php-src/sapi/cli/php_cli.c:994
#8  0x0000000000742238 in main (argc=2, argv=0xd9e900) at
/home/cbrichford/git/github/php-src/sapi/cli/php_cli.c:1378

-- 
Edit bug report at https://bugs.php.net/bug.php?id=66033&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=66033&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=66033&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=66033&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=66033&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=66033&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=66033&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=66033&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=66033&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=66033&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=66033&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=66033&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=66033&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=66033&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66033&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=66033&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=66033&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=66033&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66033&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=66033&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=66033&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#182596) next »