From dad20581913fcbe8bea59f8227f5f8df255263f6 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Mon, 17 Jul 2023 02:44:35 +0200 Subject: [PATCH] Prevent potential deadlock if accelerated globals cannot be allocated 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. --- ext/opcache/ZendAccelerator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index ed0602394ce97..f0dd678c46403 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -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));