|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2019-04-05 06:54 UTC] jordan dot ledoux at gmail dot com
[2019-04-05 18:16 UTC] jordan dot ledoux at gmail dot com
-Package: PDO MySQL
+Package: PDO Core
-PHP Version: 7.2.17
+PHP Version: 7.X
[2019-04-05 18:16 UTC] jordan dot ledoux at gmail dot com
[2019-04-05 18:52 UTC]
[2019-04-05 19:53 UTC] camporter1 at gmail dot com
[2019-04-05 21:59 UTC] johannes@php.net
[2019-04-05 22:57 UTC] krakjoe@php.net
[2019-04-05 22:57 UTC] krakjoe@php.net
-Status: Open
+Status: Closed
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 05:00:02 2025 UTC |
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