Bug #67265 [NEW]: Segmentation fault on json_encode with json_serializable
From: edu at offerum dot com
Operating system: Linux (Ubuntu 14.04)
PHP version: 5.5.12
Package: JSON related
Bug Type: Bug
Bug description:Segmentation fault on json_encode with json_serializable
Description:
------------
php-cgi segfaults when trying to encode a class which extends
json_serializable.
At least this happens when the json_serialize method unsets a variable
declared in the class.
Example in:
http://3v4l.org/TSgMV
---
From manual page: http://www.php.net/class.jsonserializable
---
Test script:
---------------
class C implements JsonSerializable {
var $a = 'lol';
var $b = 'fa';
public function jsonSerialize() {
$aux = clone($this);
unset($aux->a);
return $aux;
}
}
echo json_encode(new C()); //Ka-boom!!
Expected result:
----------------
The object json-encoded only with var $b.
Actual result:
--------------
Segmentation fault.
--
Edit bug report at https://bugs.php.net/bug.php?id=67265&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67265&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67265&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67265&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=67265&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=67265&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=67265&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=67265&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=67265&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=67265&r=support
Expected behavior: https://bugs.php.net/fix.php?id=67265&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=67265&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=67265&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=67265&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67265&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=67265&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=67265&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=67265&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=67265&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=67265&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=67265&r=mysqlcfg
Thread (10 messages)
- edu at offerum dot com