#40260 [Fbk->Opn]: PDO causing segfault in PHP
| From: | kyle at grishlan dot com | Date: | Sun, 28 Jan 2007 02:46:34 +0000 |
| Subject: | #40260 [Fbk->Opn]: PDO causing segfault in PHP | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-108143@lists.php.net to get a copy of this message | ||
ID: 40260
User updated by: kyle at grishlan dot com
Reported By: kyle at grishlan dot com
-Status: Feedback
+Status: Open
Bug Type: PDO related
Operating System: Linux-Gentoo
PHP Version: 5.2.0
New Comment:
Using 5.2 appears to fix this bug, thank you.
Previous Comments:
------------------------------------------------------------------------
[2007-01-28 01:12:30] tony2001@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.2-win32-latest.zip
------------------------------------------------------------------------
[2007-01-28 00:19:39] kyle at grishlan dot com
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 this bug report at http://bugs.php.net/?id=40260&edit=1