<?php /** * segfault test * * I encountered during app bug hunt, whereby instead of * `$w->method()` it called `$this->method()`. * * However, I discovered that infinite recursion which * usually triggers memory limit or max_recursion_depth * * For minimal testcase for segfault see: method4() */ class Y { public function method() { } } class X { public function method(): array { $ws = [new Y]; return array_map(function ($w) { return ['id' => 3, 'something' => $this->method()]; // this effectivly recurses (I was debugging a typo, this should have been `$w->method()`) }, $ws); } public function method2() { $this->method2(); } public function method3() { $a = function (){ $this->method3(); }; $a(); } // minimal testcase for segfault <---------------------- MINIMAL TESTCASE public function method4() { $a = function (){ $this->method4(); }; array_map($a,[1]); } } // original test-harnes // (new X)->method(); // Allowed memory size exhausted // (new X)->method2(); // also, Allowed memory size exhausted //(new X)->method3(); // minimal testcase for segfault (new X)->method4();
You have javascript disabled. You will not be able to edit any code.
This script was stopped while abusing our resources