php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56354 get_object_vars() segfaults on extended class
Submitted: 2005-03-19 14:45 UTC Modified: 2005-03-20 19:57 UTC
From: davey@php.net Assigned: helly (profile)
Status: Closed Package: PDO (PECL)
PHP Version: PDO 0.3 OS: *
Private report: No CVE-ID: None
 [2005-03-19 14:45 UTC] davey@php.net
Description:
------------
When extending PDO, and calling get_oject_vars($this) PHP segfaults. See reproduce script for test case.

Reproduce code:
---------------
<?php

class foo extends PDO {
    public $limit = null;
    
    function find()
    {
        $vars = get_object_vars($this);
        var_dump($vars);   
    }
}

$foo = new foo('sqlite::memory:');
$foo->find();
?>

Expected result:
----------------
var_dump() of an array containing limit => null

Actual result:
--------------
Segfault

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-19 16:35 UTC] schlueter at phpbar dot de
The problem is that PDO overrides the property handlers. 
dbh_get_properties() which is called by 
PHP_FUNCTION(get_object_vars) returns always NULL but 
expects a hash_table so it segfaults. 
 
The patch at http://www.schlueters.de/pecl.bug.3888.diff 
fixes this problem but I doubt it is the right solution 
since I'm using code which was removed by Marcus in 
pdo_dbh.c version 1.66 with the commit message "Changing 
handler table definitively results in SEGVs" so I doubt 
reintroducing this code is good. 
 
I don't know wether a non-overloaded PDO class would have 
problems always using the default handlers since the 
property hash-table these work on is available...
 [2005-03-20 19:57 UTC] helly@php.net
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 07:01:28 2024 UTC