xref: /PHP-8.3/Zend/tests/bug65784.phpt (revision 7aacc705)
1--TEST--
2Fixed Bug #65784 (Segfault with finally)
3--FILE--
4<?php
5function foo1() {
6    try {
7        throw new Exception("not catch");
8        return true;
9    } finally {
10        try {
11            throw new Exception("caught");
12        } catch (Exception $e) {
13        }
14    }
15}
16try {
17    $foo = foo1();
18    var_dump($foo);
19} catch (Exception $e) {
20    do {
21        var_dump($e->getMessage());
22    } while ($e = $e->getPrevious());
23}
24
25function foo2() {
26    try  {
27        try {
28            throw new Exception("caught");
29            return true;
30        } finally {
31            try {
32                throw new Exception("caught");
33            } catch (Exception $e) {
34            }
35        }
36    } catch (Exception $e) {
37    }
38}
39
40$foo = foo2();
41var_dump($foo);
42
43function foo3() {
44    try {
45        throw new Exception("not caught");
46        return true;
47    } finally {
48        try {
49            throw new NotExists();
50        } catch (Exception $e) {
51        }
52    }
53}
54
55$bar = foo3();
56?>
57--EXPECTF--
58string(9) "not catch"
59NULL
60
61Fatal error: Uncaught Exception: not caught in %sbug65784.php:42
62Stack trace:
63#0 %sbug65784.php(52): foo3()
64#1 {main}
65
66Next Error: Class "NotExists" not found in %s:%d
67Stack trace:
68#0 %sbug65784.php(52): foo3()
69#1 {main}
70  thrown in %sbug65784.php on line 46
71