Bug #77849 [NEW]: Unexpected segfault attempting to use cloned PDO object
| From: | jordan dot ledoux at gmail dot com | Date: | Fri, 05 Apr 2019 01:19:36 +0000 |
| Subject: | Bug #77849 [NEW]: Unexpected segfault attempting to use cloned PDO object | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-220324@lists.php.net to get a copy of this message | ||
From: jordan dot ledoux at gmail dot com
Operating system: Ubuntu (AWS AMI)
PHP version: 7.2.17
Package: PDO MySQL
Bug Type: Bug
Bug description:Unexpected segfault attempting to use cloned PDO object
Description:
------------
I encountered a segfault after attempting to use the query() method on
the PDO class after it had been unexpectedly cloned. This was actually
done on 7.2.16, but I don't have the ability to test it on other version
at the moment.
Test script:
---------------
<?php
$dsn = 'mysql:dbname=testdb;host=127.0.0.1';
$user = 'testuser';
$pass = 'testpass';
$db1 = new PDO($dsn, $user, $pass);
$result1 = $db1->query("SELECT COUNT(*) FROM
testtable"); // Will
return PDOStatement object
$db2 = clone $db1;
$result2 = $db2->query("SELECT COUNT(*) FROM testtable"); // Will
segfault
Expected result:
----------------
Since there is no case I can think of where cloning a PDO object is
necessary, I think that maybe throwing an exception of clone is used on
a PDO object would be an acceptable solution, however as I'm not an
active participant in internals I defer to the judgement of those
implementing.
This patch can be accomplished in user space as well (though obviously
not the perfect solution) by extending the PDO object and implementing a
__clone() method that always throws an exception.
Actual result:
--------------
Segmentation Fault
--
Edit bug report at https://bugs.php.net/bug.php?id=77849&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77849&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77849&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77849&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77849&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77849&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77849&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77849&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77849&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77849&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77849&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77849&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77849&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77849&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77849&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77849&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77849&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77849&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77849&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77849&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77849&r=mysqlcfg