php / php/php-src

Crash with opcache_reset() under high load in fpm

Open
#14,471 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Extension: opcache SAPI: fpm Status: Verified
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

The following code:

<?php
class T {
}

new T;
opcache_reset();

Executed under php-fpm with the following fpm configuration (save this as custom.conf):

[global]
error_log = /dev/stderr

[www]
listen = 127.0.0.1:9000
pm = static
pm.max_children = 10

Ran using: valgrind ./php-fpm -F -y custom.conf with opcache enabled.

Put under load with: ab -c 24 -n 200000 http://localhost/index.php

Resulted in this output:

==150641== Process terminating with default action of signal 6 (SIGABRT)
==150641==    at 0x4CCDE44: __pthread_kill_implementation (pthread_kill.c:44)
==150641==    by 0x4C75A2F: raise (raise.c:26)
==150641==    by 0x4C5D4C2: abort (abort.c:79)
==150641==    by 0x4C5D3DE: __assert_fail_base.cold (assert.c:94)
==150641==    by 0x4C6DC66: __assert_fail (assert.c:103)
==150641==    by 0x702B6D: zend_gc_delref (zend_types.h:1228)
==150641==    by 0x70317D: zend_string_release_ex (zend_string.h:332)
==150641==    by 0x708F6E: _php_stream_open_wrapper_ex (streams.c:2291)
==150641==    by 0x6E412B: php_stream_open_for_zend_ex (main.c:1564)
==150641==    by 0x6E407E: php_stream_open_for_zend (main.c:1552)
==150641==    by 0x7B538F9: persistent_stream_open_function (ZendAccelerator.c:2520)
==150641==    by 0x8514F6: zend_stream_open (zend_stream.c:88)

And some similar crashes, also got one crash on time in zend_accelerator_util_funcs.c in ZSTR_SET_CE_CACHE_EX(ce->name, ce, 0);.

But I expected this output instead:

Obviously not that
PHP Version

8.2

Operating System

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with php-fpm, opcache, Valgrind, and the provided ab load command. Start with the reported stack frames in ZendAccelerator.c, zend_accelerator_util_funcs.c, streams.c, and zend_types.h, then trace the crash paths. Done means the workload no longer aborts and produces the expected response.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, performance
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.