Opcache is generating different observer output
Open
Nobody has claimed this yet.
Bug
Extension: opcache
Status: Needs Triage
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
The following code:
--TEST--
Observer: Basic observability of userland methods
--EXTENSIONS--
zend_test
--INI--
zend_test.observer.enabled=1
zend_test.observer.observe_all=1
--FILE--
<?php
class TestClass
{
private function bar()
{
echo 'Bar' . PHP_EOL;
var_dump(array_reduce([1, 2, 3], fn ($a, $b) => $a + $b));
}
public function foo()
{
echo 'Foo' . PHP_EOL;
$this->bar();
}
}
$test = new TestClass();
$test->foo();
$test->foo();
$test->foo();
echo 'DONE' . PHP_EOL;
?>
Resulted in this output:
<!-- init TestClass::{closure}() --> shown 3x
But I expected this output instead:
<!-- init TestClass::{closure}() --> shown only once (as when run without opcache)
CI: https://github.com/php/php-src/actions/runs/4332385117/jobs/7564838868#step:10:156
/cc @dstogov
PHP Version
master with opcache
Operating System
any
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided observer test case with opcache enabled and compare its output with a run without opcache. Investigate why the closure initialization message appears three times instead of once; done means the opcache run matches the expected observer output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- compilers, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100