Skip to content
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
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ PHP NEWS
with a given skeleton, locale, collapse type and identity fallback.
(BogdanUngureanu)

- Fibers:
. Fixed bug GH-20483 (ASAN stack overflow with fiber.stack_size INI
small value). (David Carlier)

- Opcache:
. Fixed bug GH-20051 (apache2 shutdowns when restart is requested during
preloading). (Arnaud, welcomycozyhom)
Expand Down
16 changes: 16 additions & 0 deletions Zend/tests/fibers/gh20483.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
GH-20483 (ASAN stack overflow with small fiber.stack_size INI value)
--INI--
fiber.stack_size=1024
--FILE--
<?php
$callback = function () {};
$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
7 changes: 6 additions & 1 deletion Zend/zend_fibers.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,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;
const size_t minimum_stack_size = page_size + ZEND_FIBER_GUARD_PAGES * page_size
#ifdef __SANITIZE_ADDRESS__
// necessary correction due to ASAN redzones
* 6
#endif
;

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);
Expand Down
5 changes: 1 addition & 4 deletions ext/mbstring/mbstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -5578,19 +5578,16 @@ static bool mb_check_str_encoding(zend_string *str, const mbfl_encoding *encodin

static bool php_mb_check_encoding_recursive(HashTable *vars, const mbfl_encoding *encoding)
{
zend_long idx;
zend_string *key;
zval *entry;
bool valid = true;

(void)(idx); /* Suppress spurious compiler warning that `idx` is not used */

if (GC_IS_RECURSIVE(vars)) {
php_error_docref(NULL, E_WARNING, "Cannot not handle circular references");
return false;
}
GC_TRY_PROTECT_RECURSION(vars);
ZEND_HASH_FOREACH_KEY_VAL(vars, idx, key, entry) {
ZEND_HASH_FOREACH_STR_KEY_VAL(vars, key, entry) {
ZVAL_DEREF(entry);
if (key) {
if (!mb_check_str_encoding(key, encoding)) {
Expand Down