1--TEST--
2debug_backtrace segmentation fault with include and error handler
3--FILE--
4<?php
5class CLWrapper {
6  function stream_open($path, $mode, $options, $opened_path) {
7    return false;
8  }
9}
10
11class CL {
12  public function load($class) {
13    if (!include($class)) {
14      throw new Exception('Failed loading '.$class);
15    }
16  }
17}
18
19stream_wrapper_register('class', 'CLWrapper');
20set_error_handler(function($code, $msg, $file, $line) {
21  $bt= debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
22  echo "ERR#$code: $msg @ ", $bt[1]['function'], "\n";
23});
24
25try {
26  (new CL())->load('class://non.existent.Class');
27} catch (CLException $e) {
28  echo $e."\n";
29}
30?>
31--EXPECTF--
32ERR#2: include(class://non.existent.Class): Failed to open stream: "CLWrapper::stream_open" call failed @ include
33ERR#2: include(): Failed opening 'class://non.existent.Class' for inclusion (include_path='%s') @ include
34
35Fatal error: Uncaught Exception: Failed loading class://non.existent.Class in %s
36Stack trace:
37#0 %s(%d): CL->load('class://non.exi...')
38#1 {main}
39  thrown in %s on line %d
40