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

fix(prof): PHP 8.4 crash with opcache optimizer #3038

Merged
merged 1 commit into from
Jan 15, 2025

Conversation

morrisonlevi
Copy link
Collaborator

@morrisonlevi morrisonlevi commented Jan 14, 2025

Description

The profiler may crash when:

  1. The profiler is enabled,
  2. Allocation profiling is enabled (on by default),
  3. The application is on PHP 8.4,
  4. and Opcache is enabled and used (strongly recommended for production).

If allocation profiling triggers at a precise spot in the optimizer, then it will dereference a null pointer. The reason is that the optimizer puts a fake frame with a zeroed opline in accel_preload, and the profiler does not check for null at this location.

There are other access in the profiler to the opline such as extract_file_and_line, but they already guard against a null pointer. This specific bit of code that did not guard was added for PHP 8.4 to handle frameless functions, a new optimization in PHP 8.4.

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

The optimizer puts a fake frame with a zeroed opline in accel_preload.
@morrisonlevi morrisonlevi added cat:app-crash profiling Relates to the Continuous Profiler labels Jan 14, 2025
@morrisonlevi morrisonlevi requested a review from a team as a code owner January 14, 2025 21:40
@codecov-commenter
Copy link

codecov-commenter commented Jan 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.80%. Comparing base (46ec759) to head (38c0dda).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #3038   +/-   ##
=========================================
  Coverage     74.80%   74.80%           
  Complexity     2781     2781           
=========================================
  Files           112      112           
  Lines         11017    11017           
=========================================
  Hits           8241     8241           
  Misses         2776     2776           
Flag Coverage Δ
tracer-php 74.80% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 46ec759...38c0dda. Read the comment docs.

@pr-commenter
Copy link

pr-commenter bot commented Jan 14, 2025

Benchmarks [ profiler ]

Benchmark execution time: 2025-01-14 21:46:05

Comparing candidate commit 38c0dda in PR branch levi/fix-8.4-opline with baseline commit 46ec759 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 29 metrics, 7 unstable metrics.

@morrisonlevi morrisonlevi merged commit 52336c9 into master Jan 15, 2025
694 of 736 checks passed
@morrisonlevi morrisonlevi deleted the levi/fix-8.4-opline branch January 15, 2025 17:53
@github-actions github-actions bot added this to the 1.7.0 milestone Jan 15, 2025
realFlowControl pushed a commit that referenced this pull request Jan 17, 2025
The optimizer puts a fake frame with a zeroed opline in accel_preload.
@realFlowControl realFlowControl modified the milestones: 1.7.0, 1.6.3 Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat:app-crash profiling Relates to the Continuous Profiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants