Skip to content

Inconsistent resource loading when opcache enabled #16442

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jnvsor opened this issue Oct 14, 2024 · 8 comments
Closed

Inconsistent resource loading when opcache enabled #16442

jnvsor opened this issue Oct 14, 2024 · 8 comments

Comments

@jnvsor
Copy link

jnvsor commented Oct 14, 2024

Description

When opcache is enabled successive page loads will not have the script loaded as a resource - I was told this is probably a bug.

This script:

<?php

var_dump(get_resources());

Results in this output on the first load:

array(1) { [1]=> resource(1) of type (stream) } 

And this on the second:

array(0) { } 

The resource will be back in the list on the first request after the file is changed.

Docker build for easy repro:

FROM php:8.4.0RC2-apache-bullseye

RUN docker-php-ext-install opcache
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

PHP Version

8.4-rc2

Operating System

No response

@nono303
Copy link
Contributor

nono303 commented Oct 15, 2024

Hi!

I can confirm that php 8.4.0rc2 have trouble with opcache enabled

In my use case:

  • own build for Windows x64 NTS VS17
  • using php-cgi with httpd mod_fcgid
  • browsing on phpMyAdmin (all hit go to index.php router)
  • 🔴 having random 500 response status
! 500	 /phpmyadmin/index.php?route=/sql&pos=0&db=mydatabase&table=table1
200	 /phpmyadmin/index.php?route=%2Fmessages&l=fr&v=6.0.0-dev%2B20241009.5a82f71580
200	 /phpmyadmin/index.php?route=/navigation&ajax_request=1
200	 /phpmyadmin/index.php?route=/console/update-config
200	 /phpmyadmin/index.php?route=/database/structure/favorite-table&ajax_request=1&favorite_table=1&sync_favorite_tables=1
200	 /phpmyadmin/index.php?route=/version-check
200	 /phpmyadmin/index.php?route=/database/structure&db=mydatabase
! 500	 /phpmyadmin/index.php?route=/navigation&ajax_request=1
200	 /phpmyadmin/index.php?route=/console/update-config
! 500	 /phpmyadmin/index.php?route=/sql&pos=0&db=mydatabase&table=table2
200	 /phpmyadmin/index.php?route=/error-report
200	 /phpmyadmin/index.php?route=/navigation&ajax_request=1
200	 /phpmyadmin/index.php?route=/sql&pos=0&db=mydatabase&table=table2
200	 /phpmyadmin/index.php?route=/error-report
200	 /phpmyadmin/index.php?route=/sql&pos=0&db=mydatabase&table=table5
200	 /phpmyadmin/index.php?route=%2Fmessages&l=fr&v=6.0.0-dev%2B20241009.5a82f71580
200	 /phpmyadmin/index.php?route=/navigation&ajax_request=1
200	 /phpmyadmin/index.php?route=/console/update-config
200	 /phpmyadmin/index.php?route=/navigation&ajax_request=1
! 500	 /phpmyadmin/index.php?route=/sql&pos=0&db=mydatabase&table=table3
! 500	 /phpmyadmin/index.php?route=/sql&pos=0&db=mydatabase&table=table5
200	 /phpmyadmin/index.php?route=/sql&pos=0&db=mydatabase&table=table4
200	 /phpmyadmin/index.php?route=%2Fmessages&l=fr&v=6.0.0-dev%2B20241009.5a82f71580
200	 /phpmyadmin/index.php?route=/navigation&ajax_request=1
200	 /phpmyadmin/index.php?route=/console/update-config
200	 /phpmyadmin/index.php?route=/navigation&ajax_request=1
! 500	 /phpmyadmin/index.php?route=/sql&pos=0&db=mydatabase&table=table6
  • no log in php error.log
  • no error in opcache log opcache.log_verbosity_level=4
  • no entriy in Windows Event Log Viewer
  • having mod_fcgid error in http log
2024-10-15 08:29:31.552563 mydomain 1.2.3.4:56396 Zw4Ly_ss--S531oNTzivwAAAALg fcgid:warn fcgid_proc_win.c(363) pid:26776 tid:3724 ka:58 [get overlap result error]
2024-10-15 08:29:31.552563 mydomain 1.2.3.4:56396 Zw4Ly_ss--S531oNTzivwAAAALg core:error util_script.c(503) pid:26776 tid:3724 ka:58 [End of script output before headers: index.php]

... FcgidErrorScanInterval:60 secondes

2024-10-15 08:30:32.431166 - - - fcgid:info fcgid_proc_win.c(504) pid:26776 tid:976 [mydomain:C:/serveur/php/php-cgi.exe(39904) exit(-1073741819) communication error]
2024-10-15 08:30:32.431166 - - - fcgid:info fcgid_proc_win.c(504) pid:26776 tid:976 [mydomain:C:/serveur/php/php-cgi.exe(19048) exit(-1073741819) communication error]
2024-10-15 08:30:32.431166 - - - fcgid:info fcgid_proc_win.c(504) pid:26776 tid:976 [mydomain:C:/serveur/php/php-cgi.exe(28860) exit(-1073741819) communication error]
2024-10-15 08:30:32.431166 - - - fcgid:info fcgid_proc_win.c(504) pid:26776 tid:976 [mydomain:C:/serveur/php/php-cgi.exe(17540) exit(1) connect error, server may has exited]

Disabling opcache on 8.4.0rc2: ✅ no random 500
Rolling back to 8.4.0rc1 with opcahce enabled: ✅ no random 500

available to detail or perform other tests as needed

@jnvsor
Copy link
Author

jnvsor commented Oct 15, 2024

@nono303 I think that's a different issue, as this one also occurs on rc1

@nono303
Copy link
Contributor

nono303 commented Oct 15, 2024

@nono303 I think that's a different issue, as this one also occurs on rc1

do I move it to a new issue?

@jnvsor
Copy link
Author

jnvsor commented Oct 15, 2024

Yeah I'd say so

@nono303
Copy link
Contributor

nono303 commented Oct 15, 2024

#16449

@iluuu1994
Copy link
Member

iluuu1994 commented Oct 15, 2024

@jnvsor This is because the initial request will open the file to compile it. It is cached on subsequent request, so that step is skipped. I also wasn't aware that the opened file will be available through get_resources(). That's a bit odd, but it doesn't seem to be a bug.

<?php

$rs = get_resources();
$r = reset($rs);
print '<pre>';
var_dump($r);
var_dump(rewind($r));
var_dump(htmlspecialchars(stream_get_contents($r)));
resource(1) of type (stream)
bool(true)
string(170) "<?php

$rs = get_resources();
$r = reset($rs);
print '<pre>';
var_dump($r);
var_dump(rewind($r));
var_dump(htmlspecialchars(stream_get_contents($r)));
"

@cmb69
Copy link
Member

cmb69 commented Oct 15, 2024

From https://www.php.net/get_resources:

This function is meant for debugging and testing purposes. It is not supposed to be used in production environments, especially not to access or even manipulate resources which are normally not accessible (e.g. the underlying stream resource of SplFileObject instances).

@jnvsor
Copy link
Author

jnvsor commented Oct 15, 2024

Yeah that reads like a wontfix then. I'll go ahead and close this

@jnvsor jnvsor closed this as not planned Won't fix, can't repro, duplicate, stale Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants