1--TEST--
2Bug #79710: Reproducible segfault in error_handler during GC involved an SplFileObject
3--FILE--
4<?php
5
6class Target
7{
8    public $sfo;
9    public function __construct($sfo) {
10        $this->sfo = $sfo;
11    }
12    public function __destruct() {
13        // If the SplFileObject is destructed first,
14        // underlying FD is no longer valid and will cause error upon calling flock
15        $this->sfo->flock(2);
16    }
17}
18
19class Run
20{
21    static $sfo;
22    static $foo;
23    public static function main() {
24        // Creation ordering is important for repro
25        // $sfo needed to be destructed before $foo.
26        Run::$sfo = new SplTempFileObject();
27        Run::$foo = new Target(Run::$sfo);
28    }
29}
30
31Run::main();
32
33?>
34--EXPECTF--
35Fatal error: Uncaught Error: Object not initialized in %s:%d
36Stack trace:
37#0 %s(%d): SplFileObject->flock(2)
38#1 [internal function]: Target->__destruct()
39#2 {main}
40  thrown in %s on line %d
41