Skip to content

php still tries to unlock the shared memory ZendSem with opcache.file_cache_only=1 but it was never locked #11336

Closed
ThePHPF/thephp.foundation
#90
@tifeit

Description

@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 777 /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

if (!file_cache_only) {

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions