mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fix GH-10249: Assertion `size >= page_size + 1 * page_size' failed.
Co-authored-by: Changochen <changochen1@gmail.com> Closes GH-10284
This commit is contained in:
parent
0116864cd3
commit
833b45ac44
3 changed files with 25 additions and 1 deletions
3
NEWS
3
NEWS
|
@ -16,6 +16,9 @@ PHP NEWS
|
|||
. Fixed bug GH-10218 (DateTimeZone fails to parse time zones that contain the
|
||||
"+" character). (Derick)
|
||||
|
||||
- Fiber:
|
||||
. Fix assertion on stack allocation size. (nielsdos)
|
||||
|
||||
- FPM:
|
||||
. Fixed bug GH-9981 (FPM does not reset fastcgi.error_header).
|
||||
(Jakub Zelenka)
|
||||
|
|
17
Zend/tests/fibers/gh10249.phpt
Normal file
17
Zend/tests/fibers/gh10249.phpt
Normal file
|
@ -0,0 +1,17 @@
|
|||
--TEST--
|
||||
GH-10249 (Assertion `size >= page_size + 1 * page_size' failed.)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$callback = function () {};
|
||||
ini_set("fiber.stack_size", "");
|
||||
$fiber = new Fiber($callback);
|
||||
try {
|
||||
$fiber->start();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fiber stack size is too small, it needs to be at least %d bytes
|
|
@ -174,8 +174,12 @@ static zend_fiber_stack *zend_fiber_stack_allocate(size_t size)
|
|||
{
|
||||
void *pointer;
|
||||
const size_t page_size = zend_fiber_get_page_size();
|
||||
const size_t minimum_stack_size = page_size + ZEND_FIBER_GUARD_PAGES * page_size;
|
||||
|
||||
ZEND_ASSERT(size >= page_size + ZEND_FIBER_GUARD_PAGES * page_size);
|
||||
if (size < minimum_stack_size) {
|
||||
zend_throw_exception_ex(NULL, 0, "Fiber stack size is too small, it needs to be at least %zu bytes", minimum_stack_size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const size_t stack_size = (size + page_size - 1) / page_size * page_size;
|
||||
const size_t alloc_size = stack_size + ZEND_FIBER_GUARD_PAGES * page_size;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue