php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68137 recursive closure gives segfault evaluating zero
Submitted: 2014-10-02 20:39 UTC Modified: 2014-10-02 20:51 UTC
From: leandro at leandro dot org Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.5.17 OS: Fedora 19
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: leandro at leandro dot org
New email:
PHP Version: OS:

 

 [2014-10-02 20:39 UTC] leandro at leandro dot org
Description:
------------
i don't know what is happening
but i guess it can't eveluate (0 - 1) + (0 - 2) by some unknown reason when $n == 0

Test script:
---------------
$wop = function($n) use ( &$wop ){
     //if ($n == 0) return 1; //with this line commented, we get a segfault
     return $wop($n - 1) + $wop($n - 2);
};
print_r( array_map($wop, range(0,20)) );


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-10-02 20:51 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2014-10-02 20:51 UTC] requinix@php.net
Segfault with it... commented? Of course. You created infinite recursion.
 [2014-10-03 08:34 UTC] leandro at leandro dot org
yes, my fault. i'm very sorry. but perhaps it would be nice if i got a gentle message like "can't reach infinite" instead of a bare segfault, isn't it?
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 12:01:31 2025 UTC