php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54261 Crash when assigning value to a dimension in a non-array
Submitted: 2011-03-16 01:38 UTC Modified: 2011-07-10 13:20 UTC
From: stas@php.net Assigned:
Status: Not a bug Package: Reproducible crash
PHP Version: 5.3SVN-2011-03-16 (SVN) OS: MacOS X 10.6.6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: stas@php.net
New email:
PHP Version: OS:

 

 [2011-03-16 01:38 UTC] stas@php.net
Description:
------------
Reported by Christian Holler on mailing list, test named 
'crashMemCorruptionZvalDtorFunc', produces the following on valgrind:


==71892== Invalid read of size 4
==71892==    at 0x51D7EA: zend_hash_destroy (in /Users/smalyshev/mphp)
==71892==    by 0x50DFCC: _zval_dtor_func (in /Users/smalyshev/mphp)
==71892==    by 0x4FFB62: _zval_dtor (in /Users/smalyshev/mphp)
==71892==    by 0x4FFEB6: _zval_ptr_dtor (in /Users/smalyshev/mphp)
==71892==    by 0x5B0982: ZEND_ASSIGN_DIM_SPEC_CV_CONST_HANDLER (in 
/Users/smalyshev/mphp)
==71892==    by 0x53AB23: execute (in /Users/smalyshev/mphp)
==71892==    by 0x510794: zend_execute_scripts (in /Users/smalyshev/mphp)
==71892==    by 0x49D228: php_execute_script (in /Users/smalyshev/mphp)
==71892==    by 0x5D2CDD: main (in /Users/smalyshev/mphp)
==71892==  Address 0x5c is not stack'd, malloc'd or (recently) free'd

The bug seems to be because in ZEND_ASSIGN_DIM_SPEC_CV_CONST_HANDLER, 
error_zval_ptr is used to assign to it as if it were array, which seems to lead 
to unexpected consequences. 

Test script:
---------------
$a = '0';
var_dump(isset($a['b']));
$simpleString = preg_match('//', '', $a->a);
$simpleString["wrong"] = "f";



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-10 13:20 UTC] felipe@php.net
-Status: Open +Status: Bogus
 [2011-07-10 13:20 UTC] felipe@php.net
Duplicated of bug #54262 (already fixed)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Aug 15 05:00:02 2025 UTC