xref: /PHP-7.2/Zend/tests/bug65784.phpt (revision ce02f0f3)
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("catched");
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("catched");
29			return true;
30		} finally {
31			try {
32				throw new Exception("catched");
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 catched");
46		return true;
47	} finally {
48		try {
49			throw new NotExists();
50		} catch (Exception $e) {
51		}
52	}
53}
54
55$bar = foo3();
56--EXPECTF--
57string(9) "not catch"
58NULL
59
60Fatal error: Uncaught Exception: not catched in %sbug65784.php:42
61Stack trace:
62#0 %sbug65784.php(52): foo3()
63#1 {main}
64
65Next Error: Class 'NotExists' not found in %sbug65784.php:46
66Stack trace:
67#0 %sbug65784.php(52): foo3()
68#1 {main}
69  thrown in %sbug65784.php on line 46
70