1--TEST--
2Bug #60634 (Segmentation fault when trying to die() in SessionHandler::write()) - fatal error in write during exec
3--INI--
4session.save_path=
5session.name=PHPSESSID
6session.save_handler=files
7--EXTENSIONS--
8session
9--FILE--
10<?php
11
12ob_start();
13
14class MySessionHandler implements SessionHandlerInterface {
15    function open($save_path, $session_name): bool {
16        return true;
17    }
18
19    function close(): bool {
20        echo "close: goodbye cruel world\n";
21        return true;
22    }
23
24    function read($id): string|false {
25        return '';
26    }
27
28    function write($id, $session_data): bool {
29        echo "write: goodbye cruel world\n";
30        undefined_function();
31    }
32
33    function destroy($id): bool {
34        return true;
35    }
36
37    function gc($maxlifetime): int {
38        return 1;
39    }
40}
41session_set_save_handler(new MySessionHandler());
42session_start();
43session_write_close();
44echo "um, hi\n";
45
46/*
47FIXME: Something wrong. It should try to close after error, otherwise session
48may keep "open" state.
49*/
50
51?>
52--EXPECTF--
53write: goodbye cruel world
54
55Fatal error: Uncaught Error: Call to undefined function undefined_function() in %s:%d
56Stack trace:
57#0 [internal function]: MySessionHandler->write('%s', '')
58#1 %s(%d): session_write_close()
59#2 {main}
60  thrown in %s on line %d
61