Repository navigation
Conversation
|
@AJenbo please see whether this works for you |
|
This pull request has been marked as ready for review. |
|
@DuckThom please check the phpstan phar file from the github action artifacts to verify whether this fixes the segfaults you experienced in phpstan/phpstan#15407 |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
//cc @SanderMuller |
SanderMuller
left a comment
There was a problem hiding this comment.
I checked this locally with Homebrew PHP 8.5.8 and pcov 1.0.12, loaded from a scanned ini file. A bootstrap file logged the state of the main process and of its forked worker:
- 2.3.x (e4f45f9) with pcov enabled: no restart, and pcov is loaded and enabled in both processes.
- This PR with pcov enabled: one restart, and pcov is not loaded in either process.
- This PR with
pcov.enabled=0, or without pcov: no restart. - pcov loaded with
-d extension=on the command line: where the Turbo restart runs, it already drops pcov, so this restart does not run.
Cold self-analysis with pcov enabled, 3 interleaved rounds: the median is 33.8 s on 2.3.x and 25.1 s with this PR. Every PR run was faster than every base run. A one-file run showed no difference: the median is 1.42 s on 2.3.x and 1.31 s with this PR. Single runs took 0.8 s to 2.0 s. Without pcov or tideways nothing restarts, so nothing changes there.
make tests, make phpstan and phpcs pass on the PR head. The 4 red jobs (both shopsys/shopsys jobs, PMMP and result-cache-parse-error) also fail on #6754 and #6756.
Copilot's comment was about the earlier regex. 47ccd22 also matches extension=, and I confirmed that it removes pcov. Its second point, an e2e check that the extension is gone, is still open.
Two suggestions. The first is that second Copilot point. "Process restarting" shows that a restart ran, not that pcov is gone. At 7c5bd7f the regex matched only zend_extension=, so pcov stayed loaded, and all three jobs still passed. A bootstrap file catches that:
<?php declare(strict_types = 1);
if (extension_loaded('pcov')) {
fwrite(STDERR, "pcov is still loaded after the restart\n");
exit(1);
}With it, 7c5bd7f and 2.3.x exit with 1, and this PR exits with 0.
The second is small. In restart(), preg_replace() returns null on a PCRE error. Then null . PHP_EOL replaces the tmp ini with an empty line, and the restarted process runs without any php.ini settings. A null check before the write avoids that.
Two observations, neither of them blocking:
--xdebugandPHPSTAN_ALLOW_XDEBUGnow also keep pcov and tideways loaded. That seems like the right escape hatch, but the option's description says only "Allow running with Xdebug for debugging purposes".bin/phpstanruns the Turbo restart before this one. The tmp ini does not carry thephpstan.restartedmarker and switches OPcache off again. So the restarted process runs the Turbo restart a second time. This already happens with Xdebug. Running this check first could save one exec. That is not a small change, because the Turbo restart runs before the autoloader. I did not try it.
I did not test tideways or Windows.
|
sorry I have been taking long with my version, I got it rebased on 2.3, but still need to go over it before it's ready |
based on the feedback on the xdebug-handler project, we can subclass the XdebugHandler and override a few methods to achieve restarting in a single go.
closes #6253
closes phpstan/phpstan#15407
before this PR when pcov loaded+enabled
after this PR when pcov loaded+enabled