[php-src] Issue #11336: php still tries to unlock the shared memory ZendSem with opcache.file_cache_only=1 but it was never locked

From: Date: Mon, 29 May 2023 09:30:26 +0000
Subject: [php-src] Issue #11336: php still tries to unlock the shared memory ZendSem with opcache.file_cache_only=1 but it was never locked
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244563@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11336 Author: tifeit ### Description This is not a big deal, as the error happens in this case on PHP exit, the PHP code works, but maybe there are some other corner cases where this might be an issue. ``` mkdir /tmp/phpopcache sudo chmod 666 /tmp/phpopcache echo "<?php echo 'hi';" > test.php sudo strace -s 256 -o strace.txt -u www-data /usr/bin/php -dopcache.enable=1 -dopcache.enable_cli=1 -dopcache.file_cache_only=1 -dopcache.file_cache="/tmp/phpopcache" -dopcache.log_verbosity_level=4 -dopcache.error_log=/tmp/opcache.error -f test.php ``` will produce ``` cat /tmp/opcache.error Mon May 29 09:07:24 2023 (25731): Debug UnlockAll: Bad file descriptor (9) ``` ``` grep EBADF strace.txt fcntl(0, F_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = -1 EBADF (Bad file descriptor) ``` It seems like the lock file is created here https://github.com/php/php-src/blob/master/ext/opcache/zend_shared_alloc.c#L103 but this code is executed only when the file_cache_only=0 https://github.com/php/php-src/blob/2d883a6ff09bfc588e5d714a392a1f0e89a09926/ext/opcache/ZendAccelerator.c#L3200 i.e. the lock file is not created with file_cache_only=1 but regardless of the file_cache_only directive, the code tries to unlock it and generates the error here https://github.com/php/php-src/blob/master/ext/opcache/ZendAccelerator.c#L401 ### PHP Version 8.1.17 ### Operating System Ubuntu 18.04

« previous php.bugs (#244563) next »