Skip to content

Commit

Permalink
Fix post bailout hook execution in 8.3 unoptimized builds (#2737)
Browse files Browse the repository at this point in the history
When optimized, all is fine; however, in unoptimized builds the compiler will write stacktarget back to the stack and read it later from there, even though the stack address has moved. (i.e. only affects development builds.)

Adding register keyword to avoid this.
  • Loading branch information
bwoebi authored Jul 5, 2024
1 parent c290676 commit 3cdc077
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion zend_abstract_interface/interceptor/php8/interceptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ static void zai_hook_safe_finish(zend_execute_data *execute_data, zval *retval,
const size_t stack_top_offset = 0x400;
void *volatile stack = malloc(stack_size);
if (SETJMP(target) == 0) {
void *stacktop = stack + stack_size, *stacktarget = stacktop - stack_top_offset;
void *stacktop = stack + stack_size;
#if PHP_VERSION_ID >= 80300
register
#endif
void *stacktarget = stacktop - stack_top_offset;

#ifdef __SANITIZE_ADDRESS__
void *volatile fake_stack;
Expand Down

0 comments on commit 3cdc077

Please sign in to comment.