From: radtke at hd-system dot de
Operating system: Ubuntu 12.04
PHP version: 5.5.0
Package: PDO related
Bug Type: Bug
Bug description:Segmentation Fault by acces to class var in persitant mode
Description:
------------
create a class which extends the pdo class f.e. "extPDO"
use the persistant mode
declare a class var f.e. "$sf"
create more then 1 object of the extPDO class and
take access to the class var "$sf"
causes a segmentation fault
no seg fault if:
1. you are NOT in persistant mode
2. you just create 1 instance of the class
2. you don't declare the class var; just set it in the constructor and take
access to it
Noticed by accessing two different databases in a loop.
Test script:
---------------
class extPDO extends PDO
{
public $sf;
public function __construct($db_name, $host, $username, $passwd)
{
$dsn = 'mysql:dbname='.$db_name.';host='.$host;
$this->sf = '42';
$options = array(PDO::ATTR_PERSISTENT => true);
parent::__construct($dsn, $username, $passwd, $options);
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
}
}
function testExtPDO()
{
for($i = 1; $i <= 2; $i++){
try{
$pdo_obj = new extPDO('csp2_mycms', 'csp2-db.pille.hds', 'root', '');
$sql = 'SELECT user_id FROM user';
$pdo_st = $pdo_obj->query($sql);
if($row = $pdo_st->fetch(PDO::FETCH_ASSOC))
echo $i.'.sf:'. $pdo_obj->sf."<br>";
}
catch(Exception $e){
echo 'Exception: '.$e->getMessage().'<br>';
}
}
}
testExtPDO();
Expected result:
----------------
no segmentation fault
Actual result:
--------------
segmentation fault
--
Edit bug report at https://bugs.php.net/bug.php?id=65182&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=65182&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=65182&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=65182&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=65182&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=65182&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=65182&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=65182&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=65182&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=65182&r=support
Expected behavior: https://bugs.php.net/fix.php?id=65182&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=65182&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=65182&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=65182&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65182&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=65182&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=65182&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=65182&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65182&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=65182&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=65182&r=mysqlcfg