Skip to content

Commit

Permalink
Prevent potential deadlock if accelerated globals cannot be allocated
Browse files Browse the repository at this point in the history
Not sure if this is possible to hit in practice, zend_accel_error_noreturn
doesn't return so the unlock isn't called. Other callsites that use both
zend_accel_error_noreturn and zend_shared_alloc_unlock first perform the
unlocking.

Closes GH-11718.
  • Loading branch information
nielsdos committed Jul 17, 2023
1 parent e0aadc1 commit b0bc057
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS
Expand Up @@ -48,6 +48,8 @@ PHP NEWS
- Opcache:
. Fixed bug GH-10914 (OPCache with Enum and Callback functions results in
segmentation fault). (nielsdos)
. Prevent potential deadlock if accelerated globals cannot be allocated.
(nielsdos)

- PCNTL:
. Fixed bug GH-11498 (SIGCHLD is not always returned from proc_open).
Expand Down
2 changes: 1 addition & 1 deletion ext/opcache/ZendAccelerator.c
Expand Up @@ -2863,8 +2863,8 @@ static int zend_accel_init_shm(void)
accel_shared_globals = zend_shared_alloc(sizeof(zend_accel_shared_globals) + sizeof(uint32_t));
}
if (!accel_shared_globals) {
zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Insufficient shared memory!");
zend_shared_alloc_unlock();
zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Insufficient shared memory!");
return FAILURE;
}
memset(accel_shared_globals, 0, sizeof(zend_accel_shared_globals));
Expand Down

0 comments on commit b0bc057

Please sign in to comment.