#40260 [NEW]: PDO causing segfault in PHP
| From: | kyle at grishlan dot com | Date: | Sun, 28 Jan 2007 00:19:39 +0000 |
| Subject: | #40260 [NEW]: PDO causing segfault in PHP | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-108135@lists.php.net to get a copy of this message | ||
From: kyle at grishlan dot com
Operating system: Linux-Gentoo
PHP version: 5.2.0
PHP Bug Type: PDO related
Bug description: PDO causing segfault in PHP
Description:
------------
I have a PDO object connecting to a MySQL database, and I pass the object
to the __construct function of a new object. In the __construct function,
I attempt to make prepared statement with the PDO object, and if I then
exit(1) or die(), without unsetting the PDOStatement object, PHP
segfaults.
This is a similar bug to http://bugs.php.net/bug.php?id=37445 (In that it
has the same final few functions in the backtrace), but I don't believe it
to be the same issue. I have also tried (per that bug's comments)
mysql_statement.c versions 1.48.2.12, 1.48.2.13, 1.48.2.14, and
1.48.2.14.2.2, but they've all reproduced the problem.
My PHP is version 5.1.6-r6 (I'm not running 5.2+ as it's not currently in
the gentoo repository.
Reproduce code:
---------------
<?php
class MyClass
{
public function __construct($pdo)
{
$stmt = $pdo->prepare("SELECT * FROM my_table_name");
$stmt->execute();
while ($row = $stmt->fetch())
print_r($row);
$stmt->closeCursor();
// Commenting this out makes PHP segfault
unset($stmt);
// Commenting this out (if commented above) fixes the
segfault
exit(1);
}
};
$pdo = new PDO('mysql:host=localhost;dbname=my_db_name', 'root', '');
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, TRUE);
$myclass = new MyClass($pdo);
?>
Expected result:
----------------
No output.
Actual result:
--------------
Segmentation fault (backtrace provided below)
(gdb) backt
#0 0xb76566ae in mysql_more_results (mysql=0x5a5a5a5a) at
libmysql.c:5136
#1 0x081cd839 in pdo_mysql_stmt_dtor (stmt=0x87fb374)
at
/var/tmp/portage/php-5.1.6-r6/work/php-5.1.6/ext/pdo_mysql/mysql_statement.c:71
#2 0x081c5897 in free_statement (stmt=0x87fb374)
at
/var/tmp/portage/php-5.1.6-r6/work/php-5.1.6/ext/pdo/pdo_stmt.c:2200
#3 0x08309d58 in zend_objects_store_free_object_storage
(objects=0x86815ec)
at
/var/tmp/portage/php-5.1.6-r6/work/php-5.1.6/Zend/zend_objects_API.c:86
#4 0x082e23bb in shutdown_executor ()
at
/var/tmp/portage/php-5.1.6-r6/work/php-5.1.6/Zend/zend_execute_API.c:281
#5 0x082eddfd in zend_deactivate ()
at /var/tmp/portage/php-5.1.6-r6/work/php-5.1.6/Zend/zend.c:854
#6 0x082aa5a3 in php_request_shutdown (dummy=0x0)
at /var/tmp/portage/php-5.1.6-r6/work/php-5.1.6/main/main.c:1292
#7 0x0837e7aa in main (argc=2, argv=0xbf910804)
at
/var/tmp/portage/php-5.1.6-r6/work/php-5.1.6/sapi/cli/php_cli.c:1246
--
Edit bug report at http://bugs.php.net/?id=40260&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40260&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40260&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40260&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40260&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=40260&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=40260&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=40260&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=40260&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=40260&r=support
Expected behavior: http://bugs.php.net/fix.php?id=40260&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=40260&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=40260&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40260&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40260&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40260&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=40260&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=40260&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=40260&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=40260&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=40260&r=mysqlcfg