Skip to content
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

From time to time: PHP Fatal error: Uncaught ValueError: fread(): Argument #2 ($length) must be greater than 0 #3

Closed
iammeken opened this issue Jun 23, 2023 · 3 comments
Assignees
Labels
bug Something isn't working as expected

Comments

@iammeken
Copy link

FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught ValueError: fread(): Argument #2 ($length) must be greater than 0 in xxx/counter/counter.php:209
Stack trace:
#0 xxx/counter/counter.php(209): fread()
#1 xxx/counter/counter.php(234): Esi\SimpleCounter\Counter->readWriteFile()
#2 xxx/counter/counter.php(273): Esi\SimpleCounter\Counter->process()
#3 xxx/index.php(401): include('...')
#4 {main}
thrown in xxx/counter/counter.php on line 209" while reading upstream,

@ericsizemore ericsizemore self-assigned this Jun 24, 2023
@ericsizemore ericsizemore added the bug Something isn't working as expected label Jun 24, 2023
@ericsizemore
Copy link
Owner

Thank you for the report @iammeken :) I've never personally encountered this issue, however, could you try something for me? I believe this will resolve it for you.

In counter.php find:

if (self::USE_FLOCK AND \flock($fp, \LOCK_EX)) {

And before that, add:

\clearstatcache();

Should look something like this:

\clearstatcache();

if (self::USE_FLOCK AND \flock($fp, \LOCK_EX)) {

@iammeken
Copy link
Author

I guess it was caused by naughty visitors/bots.

FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught TypeError: Unsupported operand types: string + int in xxx/counter/counter.php:252
Stack trace:
#0  xxx/counter/counter.php(274): Esi\SimpleCounter\Counter->process()
#1  xxx/index.php(401): include('...')
#2 {main}
  thrown in xxx/counter/counter.php on line 252" while reading upstream, client: 90.156.169.15, server: default, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.2-fpm.sock:", host: "xxx.com"
2023/06/25 05:28:02 [error] 2168#2168: *327204 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught ValueError: fread(): Argument #2 ($length) must be greater than 0 in xxx/counter/counter.php:210
Stack trace:
#0  xxx/counter/counter.php(210): fread()
#1  xxx/counter/counter.php(235): Esi\SimpleCounter\Counter->readWriteFile()
#2  xxx/counter/counter.php(274): Esi\SimpleCounter\Counter->process()
#3  xxx/index.php(401): include('...')
#4 {main}

@iammeken
Copy link
Author

I checked one such ip address:

They visited the script via several different domains at the same second.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

2 participants