-
Notifications
You must be signed in to change notification settings - Fork 160
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(profiling): potential allocation profiling crashes with certain opcodes #2352
fix(profiling): potential allocation profiling crashes with certain opcodes #2352
Conversation
BenchmarksBenchmark execution time: 2023-12-29 17:05:07 Comparing candidate commit c004213 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 18 metrics, 3 unstable metrics. |
profiling/src/php_ffi.c
Outdated
|
||
/* Issue is fixed in 8.0.12: | ||
* https://github.com/php/php-src/commit/ec54ffad1e3b15fedfd07f7d29d97ec3e8d1c45a | ||
* The tracer didn't save us here. Fortunately, throwing destru |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: fix this comment lol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I remember. It is not only about fixing the comment, but try and see if the fix is enough, as there is a zend_array_dup()
call few lines before the SAVE_OPLINE()
happens. I'll check if I can trigger this, I highly assume it will crash as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we need to adjust the version range too. If the bad opline is still on PHP 8.0.12+, then we need to install the opcode handler on more versions too (maybe up to latest 😞).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jup, we need to install up to latest, can you check bf3fd02
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I add another commit that cleans things up and adds a pointless test for ZEND_BIND_STATIC
with a todo.
8ec66a9
to
ad46787
Compare
I moved this back to draft. I need to figure out:
|
|
3c8cceb
to
60dccae
Compare
This reverts commit e4ee56c.
Also clean up some warnings and XFAIL a test until upstream is fixed.
Preloading and opcode handlers both tied to having the post-startup callback. Previously the startup callback was tied to the preload feature. This separates them.
ea2e364
to
1b6cbc3
Compare
@morrisonlevi I added |
@realFlowControl Thank you! It looks good to me. I merged in master and added your upstream phpt with a long-form description. Can you do a final code review? |
16a35aa
to
c004213
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
I also like set_run_time_php_version_id being moved to C code, looks much more readable there.
Description
TODO: update the whole description for state of the current patch.
On PHP 7.4 and on PHP 8.0 before 8.0.26, the engine doesn't
SAVE_OPLINE();
for theZEND_GENERATOR_CREATE
opcode. If the allocation profiler triggers on an allocation in this state, then it will sigsegv because the opline is non-null but invalid.Note that the
SAVE_OPLINE();
is missing on PHP < 7.4 as well, but on those versionsi_init_func_execute_data
initializes the opline. Coupled with the new test, we are confident that we don't need to install an opcode handler for those versions.Who is affected by the crash?
Everything else is unaffected. To be clear:
In summary, no known customers are affected. Nearly everyone on PHP 7 runs the tracer, and nearly everyone is on a patched version of PHP 8.0, or on PHP 8.1 or newer. If you are on an affected version of PHP 8.0, as a quick mitigation you can disable the allocation profile by setting the ini
datadog.profiling.allocation_enabled=0
. You can do this with config mode of the setup script:Readiness checklist
Reviewer checklist