bug79710.phpt 931 B

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