php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #75939 opcache_invalidate requires file presence
Submitted: 2018-02-08 20:21 UTC Modified: 2021-03-03 14:54 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: bjornar dot ness at gmail dot com Assigned:
Status: Open Package: opcache
PHP Version: 7.2.2 OS: n/a
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bjornar dot ness at gmail dot com
New email:
PHP Version: OS:

 

 [2018-02-08 20:21 UTC] bjornar dot ness at gmail dot com
Description:
------------
opcache_invalidate()/zend_accel_invalidate does:

        realpath = accelerator_orig_zend_resolve_path(filename, filename_len);

        if (!realpath) {
                return FAILURE;
        }

accelerator_orig_zend_resolve_path ends up calling php_resolve_path that again
does a tsrm_realpath() that ends up doing lstat() that in the end makes php_resolve_path return NULL and zend_accel_invalidate return FAILURE.

This means it is not possible to invalidate a file that is removed from the filesystem without flushing the entire opcache. This can be problematic in general and for esoteric in particular.

I understand the fact that one might try to resolve symlinks to find real cache key, but there should imho be a way to override this and enable the invalidation.

Another related issue is that opcache_invalidate does not actually free up memory, just marks the cached code as corrupted. How impossible would it
be to implement a opcache_delete call that would do all this?


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-03-03 14:48 UTC] cmb@php.net
> How impossible would it be to implement a opcache_delete call
> that would do all this?

Not impossible, but inefficient, see "So OPCache is clever about
shared memory, and will not fragment it by freeing it and
compacting it."[1]

[1] <http://blog.jpauli.tech/2015-03-05-opcache-html/>
 [2021-03-03 14:54 UTC] bjornar dot ness at gmail dot com
Imho, this has nothing to do with fragmentation, if the file exists on disk or not..
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 08 08:01:29 2024 UTC