Skip to content

Fix GH-17727: JIT SEGV on OOM in dtor when creating backtrace #17732

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

Closed
wants to merge 2 commits into from

Conversation

nielsdos
Copy link
Member

@nielsdos nielsdos commented Feb 7, 2025

This became visible after GH-17056 was merged, but technically the lack of setting the opline is also present on lower branches. We set the opline to mirror the SAVE_OPLINE() from ZEND_INIT_STATIC_METHOD_CALL().

Targeting master, but I can merge into 8.4 (except the test) and make equivalent changes to 8.3 if wanted.

This became visible after phpGH-17056 was merged, but technically the lack
of setting the opline is also present on lower branches.
We set the opline to mirror the SAVE_OPLINE() from
ZEND_INIT_STATIC_METHOD_CALL().
@nielsdos nielsdos linked an issue Feb 7, 2025 that may be closed by this pull request
@nielsdos nielsdos marked this pull request as ready for review February 7, 2025 19:12
@nielsdos nielsdos requested a review from dstogov as a code owner February 7, 2025 19:12
Copy link
Member

@dstogov dstogov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect, now we have to keep consistent EX(opline) state before each memory allocation (including possible indirect allocations)...

Why this might be a problem before (for PHP-8.4)?

@nielsdos
Copy link
Member Author

I suspect, now we have to keep consistent EX(opline) state before each memory allocation (including possible indirect allocations)...

This is probably true

Why this might be a problem before (for PHP-8.4)?

I remembered this discussion: #12648 where they wanted to add SAVE_OPLINE before allocations to get the right (non-NULL, up-to-date) opline when an OOM happens. Out of sync opline seemed to have caused crashes in 3rd party extensions before and also in the core PHP (fixed in #10003 by adding a NULL check). Perhaps we can just add a NULL check although that may make an inconsistency between JIT and VM.

@dstogov
Copy link
Member

dstogov commented Feb 11, 2025

I don't see a big problem adding SAVE_OPLINE() in this single place, but I wouldn't like to add it before each potential memory allocation.

@nielsdos
Copy link
Member Author

but I wouldn't like to add it before each potential memory allocation.

I agree, I also would not like that, and I expressed that in the linked PR already.
I think however, we are "lucky" that many places already have the opline set (or at least non-NULL) before allocating.

@dstogov
Copy link
Member

dstogov commented Feb 17, 2025

I agree, I also would not like that, and I expressed that in the linked PR already. I think however, we are "lucky" that many places already have the opline set (or at least non-NULL) before allocating.

I don't object against this commit.

@nielsdos nielsdos closed this in a54ed9e Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JIT SEGV on OOM in dtor when creating backtrace
2 participants