Skip to content

GC fiber unfinished executions #9810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions Zend/tests/fibers/gh9735-001.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
--TEST--
Bug GH-9735 001 (Fiber stack variables do not participate in cycle collector)
--FILE--
<?php

class C {
public function __destruct() {
echo __METHOD__, "\n";
}
}

$fiber = new Fiber(function () {
$c = new C();

$fiber = Fiber::getCurrent();

Fiber::suspend();
});

print "1\n";

$fiber->start();
gc_collect_cycles();

print "2\n";

$fiber = null;
gc_collect_cycles();

print "3\n";

?>
--EXPECT--
1
2
C::__destruct
3
41 changes: 41 additions & 0 deletions Zend/tests/fibers/gh9735-002.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
--TEST--
Bug GH-9735 002 (Fiber stack variables do not participate in cycle collector)
--FILE--
<?php

class C {
public function __destruct() {
echo __METHOD__, "\n";
}
}

function f() {
Fiber::suspend();
}

$fiber = new Fiber(function () {
$c = new C();

$fiber = Fiber::getCurrent();

f();
});

print "1\n";

$fiber->start();
gc_collect_cycles();

print "2\n";

$fiber = null;
gc_collect_cycles();

print "3\n";

?>
--EXPECT--
1
2
C::__destruct
3
40 changes: 40 additions & 0 deletions Zend/tests/fibers/gh9735-003.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
--TEST--
Bug GH-9735 003 (Fiber stack variables do not participate in cycle collector)
--FILE--
<?php

class C {
public function __destruct() {
echo __METHOD__, "\n";
}
}

function f() {
$fiber = Fiber::getCurrent();
Fiber::suspend();
}

$fiber = new Fiber(function () {
$c = new C();

f();
});

print "1\n";

$fiber->start();
gc_collect_cycles();

print "2\n";

$fiber = null;
gc_collect_cycles();

print "3\n";

?>
--EXPECT--
1
2
C::__destruct
3
40 changes: 40 additions & 0 deletions Zend/tests/fibers/gh9735-004.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
--TEST--
Bug GH-9735 004 (Fiber stack variables do not participate in cycle collector)
--FILE--
<?php

class C {
public function __destruct() {
echo __METHOD__, "\n";
}
}

function f() {
$fiber = Fiber::getCurrent();
Fiber::suspend();
}

$fiber = new Fiber(function () {
$c = new C();

preg_replace_callback('#.#', f(...), '.');
});

print "1\n";

$fiber->start();
gc_collect_cycles();

print "2\n";

$fiber = null;
gc_collect_cycles();

print "3\n";

?>
--EXPECT--
1
2
C::__destruct
3
44 changes: 44 additions & 0 deletions Zend/tests/fibers/gh9735-005.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
--TEST--
Bug GH-9735 005 (Fiber stack variables do not participate in cycle collector)
--FILE--
<?php

class C {
public function __destruct() {
echo __METHOD__, "\n";
}
}

function f() {
Fiber::suspend();
}

$fiber = new Fiber(function () {
$c = new C();

$fiber = Fiber::getCurrent();

// Force symbol table
get_defined_vars();

f();
});

print "1\n";

$fiber->start();
gc_collect_cycles();

print "2\n";

$fiber = null;
gc_collect_cycles();

print "3\n";

?>
--EXPECTF--
1
2
C::__destruct
3
47 changes: 47 additions & 0 deletions Zend/tests/fibers/gh9735-006.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
--TEST--
Bug GH-9735 006 (Fiber stack variables do not participate in cycle collector)
--FILE--
<?php

class C {
public function __destruct() {
echo __METHOD__, "\n";
}
}

function f() {
// Force symbol table
get_defined_vars();

Fiber::suspend();
}

$fiber = new Fiber(function () {
$c = new C();

$fiber = Fiber::getCurrent();

// Force symbol table
get_defined_vars();

f();
});

print "1\n";

$fiber->start();
gc_collect_cycles();

print "2\n";

$fiber = null;
gc_collect_cycles();

print "3\n";

?>
--EXPECTF--
1
2
C::__destruct
3
47 changes: 47 additions & 0 deletions Zend/tests/fibers/gh9735-007.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
--TEST--
Bug GH-9735 007 (Fiber stack variables do not participate in cycle collector)
--FILE--
<?php

class C {
public function __destruct() {
echo __METHOD__, "\n";
}
}

function f() {
$fiber = Fiber::getCurrent();

// Force symbol table
get_defined_vars();

Fiber::suspend();
}

$fiber = new Fiber(function () {
$c = new C();

// Force symbol table
get_defined_vars();

f();
});

print "1\n";

$fiber->start();
gc_collect_cycles();

print "2\n";

$fiber = null;
gc_collect_cycles();

print "3\n";

?>
--EXPECTF--
1
2
C::__destruct
3
42 changes: 42 additions & 0 deletions Zend/tests/fibers/gh9735-008.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
--TEST--
Bug GH-9735 008 (Fiber stack variables do not participate in cycle collector)
--FILE--
<?php

class C {
public function __destruct() {
echo __METHOD__, "\n";
}
}

function f($a, $b) {
}

function g() {
Fiber::suspend();
}

$fiber = new Fiber(function () {
$c = new C();

f(Fiber::getCurrent(), g());
});

print "1\n";

$fiber->start();
gc_collect_cycles();

print "2\n";

$fiber = null;
gc_collect_cycles();

print "3\n";

?>
--EXPECTF--
1
2
C::__destruct
3
42 changes: 42 additions & 0 deletions Zend/tests/fibers/gh9735-009.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
--TEST--
Bug GH-9735 009 (Fiber stack variables do not participate in cycle collector)
--FILE--
<?php

class C {
public function __destruct() {
echo __METHOD__, "\n";
}
}

function f($a, $b) {
}

function g() {
g(Fiber::suspend());
}

$fiber = new Fiber(function () {
$c = new C();

f(Fiber::getCurrent(), g());
});

print "1\n";

$fiber->start();
gc_collect_cycles();

print "2\n";

$fiber = null;
gc_collect_cycles();

print "3\n";

?>
--EXPECTF--
1
2
C::__destruct
3
Loading