|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78031 __toString segmentation fault
Submitted: 2019-05-18 01:45 UTC Modified: 2019-05-18 08:13 UTC
From: gmblar+php at gmail dot com Assigned: cmb (profile)
Status: Duplicate Package: Scripting Engine problem
PHP Version: Irrelevant OS: macOS 10.14.5
Private report: No CVE-ID: None
 [2019-05-18 01:45 UTC] gmblar+php at gmail dot com
PHP crashes with "Segmentation fault: 11" if you access $this->$this in __toString.

maybe related to:


Test script:

class Foobar {
    public function __toString() {


$foobar = new Foobar();
(string) $foobar;

Expected result:
no segmentation fault

Actual result:
Segmentation fault: 11


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-05-18 08:13 UTC]
-Status: Open +Status: Duplicate -Package: PDO related +Package: Scripting Engine problem -Assigned To: +Assigned To: cmb
 [2019-05-18 08:13 UTC]
This is actually a duplicate of the mentioned tickets.  In this
case trying to convert the variable property name $this to string
calls Foobar::__toString() again, and so on, till the machine
stack is exhausted.

Note that we consider infinite recursion to be a userland
programming error.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jul 20 03:02:00 2024 UTC