php.net |  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
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: gmblar+php at gmail dot com
New email:
PHP Version: OS:

 

 [2019-05-18 01:45 UTC] gmblar+php at gmail dot com
Description:
------------
PHP crashes with "Segmentation fault: 11" if you access $this->$this in __toString.

maybe related to:

* https://bugs.php.net/bug.php?id=53858
* https://bugs.php.net/bug.php?id=67319

https://3v4l.org/Rt2Qj/perf#output

Test script:
---------------
<?php

class Foobar {
    
    public function __toString() {
        $this->$this;
    }

}

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


Expected result:
----------------
no segmentation fault

Actual result:
--------------
Segmentation fault: 11

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-05-18 08:13 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Package: PDO related +Package: Scripting Engine problem -Assigned To: +Assigned To: cmb
 [2019-05-18 08:13 UTC] cmb@php.net
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: Fri Dec 27 13:01:27 2024 UTC