|  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
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 Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
26 + 6 = ?
Subscribe to this entry?

 [2018-02-08 20:21 UTC] bjornar dot ness at gmail dot com
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?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-03-03 14:48 UTC]
> 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] <>
 [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: Sat May 18 01:01:33 2024 UTC