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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 16:01:36 2024 UTC