Bug #67265 [Opn->Nab]: Segmentation fault on json_encode with json_serializable
| From: | tyrael@php.net | Date: | Tue, 13 May 2014 19:44:37 +0000 |
| Subject: | Bug #67265 [Opn->Nab]: Segmentation fault on json_encode with json_serializable | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-185808@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67265&edit=1
ID: 67265
Updated by: tyrael@php.net
Reported by: edu at offerum dot com
Summary: Segmentation fault on json_encode with
json_serializable
-Status: Open
+Status: Not a bug
Type: Bug
Package: JSON related
Operating System: Linux (Ubuntu 14.04)
PHP Version: 5.5.12
Block user comment: N
Private report: N
New Comment:
while I agree that this isn't nice, but we have a bunch of other cases when infinite recursion
will result in a segfault (for example http://3v4l.org/uhInN),
and mike is right about that we close these kind of reports as not a bug/won't fix, for example
https://bugs.php.net/bug.php?id=51350 or https://bugs.php.net/bug.php?id=64280
We even had a pull request which could have fixed some of those cases
(https://github.com/php/php-src/pull/290) but it was declined as something we don't need in the
core.
If you think it is worth your time, please bring this up on the internals mailing list so maybe we
can make a different agreement this time.
Previous Comments:
------------------------------------------------------------------------
[2014-05-13 15:29:30] levim@php.net
Mike,
Generally we do not consider segfaults as acceptable behavior. Instead we need to fail nicely. This
*is* a bug.
------------------------------------------------------------------------
[2014-05-13 15:22:34] mike@php.net
Still, not a bug.
------------------------------------------------------------------------
[2014-05-13 15:21:14] edu at offerum dot com
Yep, I was wrong thinking it has something to do with deleting object variables.
Indeed, the behaviour can be seen pretty clear here:
class C implements JsonSerializable {
public function jsonSerialize() {
$a = clone($this);
echo 1;
return $a;
}
}
echo json_encode(new C());
Example:
http://3v4l.org/nRMRj
------------------------------------------------------------------------
[2014-05-13 15:19:26] mike@php.net
Yep. This is not a bug but infinite recursion.
------------------------------------------------------------------------
[2014-05-13 15:18:08] levim@php.net
My $0.02; find some way to protect against recursion and then fail nicely.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=67265
--
Edit this bug report at https://bugs.php.net/bug.php?id=67265&edit=1