-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
1,844 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--TEST-- | ||
Stack limit 001 - Stack limit checks with max_allowed_stack_size detection | ||
--EXTENSIONS-- | ||
zend_test | ||
--INI-- | ||
; The test may use a large amount of memory on systems with a large stack limit | ||
memory_limit=2G | ||
--FILE-- | ||
<?php | ||
|
||
var_dump(zend_test_zend_call_stack_get()); | ||
|
||
class Test1 { | ||
public function __destruct() { | ||
new Test1; | ||
} | ||
} | ||
|
||
class Test2 { | ||
public function __clone() { | ||
clone $this; | ||
} | ||
} | ||
|
||
class Test3 { | ||
public function __sleep() | ||
{ | ||
serialize($this); | ||
} | ||
} | ||
|
||
function replace() { | ||
return preg_replace_callback('#.#', function () { | ||
return replace(); | ||
}, 'x'); | ||
} | ||
|
||
try { | ||
new Test1; | ||
} catch (Error $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
|
||
try { | ||
clone new Test2; | ||
} catch (Error $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
|
||
try { | ||
serialize(new Test3); | ||
} catch (Error $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
|
||
try { | ||
replace(); | ||
} catch (Error $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
array(4) { | ||
["base"]=> | ||
string(%d) "0x%x" | ||
["max_size"]=> | ||
string(%d) "0x%x" | ||
["position"]=> | ||
string(%d) "0x%x" | ||
["EG(stack_limit)"]=> | ||
string(%d) "0x%x" | ||
} | ||
Maximum call stack size of %d bytes reached. Infinite recursion? | ||
Maximum call stack size of %d bytes reached. Infinite recursion? | ||
Maximum call stack size of %d bytes reached. Infinite recursion? | ||
Maximum call stack size of %d bytes reached. Infinite recursion? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--TEST-- | ||
Stack limit 002 - Stack limit checks with max_allowed_stack_size detection (fibers) | ||
--EXTENSIONS-- | ||
zend_test | ||
--INI-- | ||
fiber.stack_size=512k | ||
--FILE-- | ||
<?php | ||
|
||
var_dump(zend_test_zend_call_stack_get()); | ||
|
||
class Test1 { | ||
public function __destruct() { | ||
new Test1; | ||
} | ||
} | ||
|
||
class Test2 { | ||
public function __clone() { | ||
clone $this; | ||
} | ||
} | ||
|
||
class Test3 { | ||
public function __sleep() | ||
{ | ||
serialize($this); | ||
} | ||
} | ||
|
||
function replace() { | ||
return preg_replace_callback('#.#', function () { | ||
return replace(); | ||
}, 'x'); | ||
} | ||
|
||
$fiber = new Fiber(function (): void { | ||
try { | ||
new Test1; | ||
} catch (Error $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
|
||
try { | ||
clone new Test2; | ||
} catch (Error $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
|
||
try { | ||
serialize(new Test3); | ||
} catch (Error $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
|
||
try { | ||
replace(); | ||
} catch (Error $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
}); | ||
|
||
$fiber->start(); | ||
|
||
?> | ||
--EXPECTF-- | ||
array(4) { | ||
["base"]=> | ||
string(%d) "0x%x" | ||
["max_size"]=> | ||
string(%d) "0x%x" | ||
["position"]=> | ||
string(%d) "0x%x" | ||
["EG(stack_limit)"]=> | ||
string(%d) "0x%x" | ||
} | ||
Maximum call stack size of %d bytes reached. Infinite recursion? | ||
Maximum call stack size of %d bytes reached. Infinite recursion? | ||
Maximum call stack size of %d bytes reached. Infinite recursion? | ||
Maximum call stack size of %d bytes reached. Infinite recursion? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--TEST-- | ||
Stack limit 003 - Stack limit checks with fixed max_allowed_stack_size | ||
--EXTENSIONS-- | ||
zend_test | ||
--INI-- | ||
zend.max_allowed_stack_size=128K | ||
--FILE-- | ||
<?php | ||
|
||
var_dump(zend_test_zend_call_stack_get()); | ||
|
||
class Test1 { | ||
public function __destruct() { | ||
new Test1; | ||
} | ||
} | ||
|
||
class Test2 { | ||
public function __clone() { | ||
clone $this; | ||
} | ||
} | ||
|
||
function replace() { | ||
return preg_replace_callback('#.#', function () { | ||
return replace(); | ||
}, 'x'); | ||
} | ||
|
||
try { | ||
new Test1; | ||
} catch (Error $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
|
||
try { | ||
clone new Test2; | ||
} catch (Error $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
|
||
try { | ||
replace(); | ||
} catch (Error $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
array(4) { | ||
["base"]=> | ||
string(%d) "0x%x" | ||
["max_size"]=> | ||
string(%d) "0x%x" | ||
["position"]=> | ||
string(%d) "0x%x" | ||
["EG(stack_limit)"]=> | ||
string(%d) "0x%x" | ||
} | ||
Maximum call stack size of %d bytes reached. Infinite recursion? | ||
Maximum call stack size of %d bytes reached. Infinite recursion? | ||
Maximum call stack size of %d bytes reached. Infinite recursion? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--TEST-- | ||
Stack limit 004 - Stack limit checks with fixed max_allowed_stack_size (fibers) | ||
--EXTENSIONS-- | ||
zend_test | ||
--FILE-- | ||
<?php | ||
|
||
var_dump(zend_test_zend_call_stack_get()); | ||
|
||
class Test1 { | ||
public function __destruct() { | ||
new Test1; | ||
} | ||
} | ||
|
||
$callback = function (): int { | ||
try { | ||
new Test1; | ||
} catch (Error $e) { | ||
return count($e->getTrace()); | ||
} | ||
|
||
throw new \Exception(); | ||
}; | ||
|
||
ini_set('fiber.stack_size', '400K'); | ||
$fiber = new Fiber($callback); | ||
$fiber->start(); | ||
$depth1 = $fiber->getReturn(); | ||
|
||
ini_set('fiber.stack_size', '200K'); | ||
$fiber = new Fiber($callback); | ||
$fiber->start(); | ||
$depth2 = $fiber->getReturn(); | ||
|
||
var_dump($depth1 > $depth2); | ||
|
||
?> | ||
--EXPECTF-- | ||
array(4) { | ||
["base"]=> | ||
string(%d) "0x%x" | ||
["max_size"]=> | ||
string(%d) "0x%x" | ||
["position"]=> | ||
string(%d) "0x%x" | ||
["EG(stack_limit)"]=> | ||
string(%d) "0x%x" | ||
} | ||
bool(true) |
Oops, something went wrong.