xref: /PHP-8.4/ext/standard/tests/array/bug35821.phpt (revision f8d79582)
1--TEST--
2Bug #35821 (array_map() segfaults when exception is throwed from the callback)
3--FILE--
4<?php
5
6class Element
7{
8    public function ThrowException ()
9    {
10        throw new Exception();
11    }
12
13    public static function CallBack(Element $elem)
14    {
15        $elem->ThrowException();
16    }
17}
18
19$arr = array(new Element(), new Element(), new Element());
20array_map(array('Element', 'CallBack'), $arr);
21
22echo "Done\n";
23?>
24--EXPECTF--
25Fatal error: Uncaught Exception in %s:%d
26Stack trace:
27#0 %s(%d): Element->ThrowException()
28#1 [internal function]: Element::CallBack(Object(Element))
29#2 %s(%d): array_map(Array, Array)
30#3 {main}
31  thrown in %s on line %d
32