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