mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Fix stack limit under valgrind (#14818)
Valgrind creates a stack mapping that can grow up to RLIMIT_STACK, but the last page is never useable
This commit is contained in:
@@ -71,6 +71,10 @@ typedef int boolean_t;
|
||||
#include <thread.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_VALGRIND
|
||||
# include <valgrind/valgrind.h>
|
||||
#endif
|
||||
|
||||
#ifdef ZEND_CHECK_STACK_LIMIT
|
||||
|
||||
/* Called once per process or thread */
|
||||
@@ -238,6 +242,13 @@ static bool zend_call_stack_get_linux_proc_maps(zend_call_stack *stack)
|
||||
|
||||
max_size = rlim.rlim_cur;
|
||||
|
||||
#ifdef HAVE_VALGRIND
|
||||
/* Under Valgrind, the last page is not useable */
|
||||
if (RUNNING_ON_VALGRIND) {
|
||||
max_size -= zend_get_page_size();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Previous mapping may prevent the stack from growing */
|
||||
if (end - max_size < prev_end) {
|
||||
max_size = prev_end - end;
|
||||
|
||||
Reference in New Issue
Block a user