gc_033.phpt 562 B

123456789101112131415161718192021222324252627282930
  1. --TEST--
  2. GC 033: Crash in GC while run with phpspec
  3. --INI--
  4. zend.enable_gc = 1
  5. --FILE--
  6. <?php
  7. $a = new stdClass();
  8. $a->a = array();
  9. $a->a[0] = new Stdclass();
  10. $a->a[0]->a = $a;
  11. $a->a[1] = &$a->a;
  12. /* remove the self-reference array out of roots */
  13. gc_collect_cycles();
  14. /* do unset */
  15. unset($a);
  16. /* let's full the gc roots */
  17. for ($i=0; $i<9999; $i++) {
  18. $b = range(0, 1);
  19. $b[0] = &$b;
  20. unset($b);
  21. }
  22. /* then $a will be freed, but $a->a[0] is not. reference to a freed $a */
  23. var_dump(gc_collect_cycles());
  24. ?>
  25. --EXPECT--
  26. int(10002)