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 infinite recursion on deprecated attribute evaluation #17712

Open
wants to merge 1 commit into
base: PHP-8.4
Choose a base branch
from

Conversation

iluuu1994
Copy link
Member

Fixes GH-17711

Discovered in GH-16952, where the issue is more obvious to reproduce. Optimally, this could have been moved into zend_deprecated_class_constant() to avoid duplication, but that's not possible because it marks the c as const.

Copy link
Member

@TimWolla TimWolla left a comment

Choose a reason for hiding this comment

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

The fix makes sense to me and is consistent with the existing MARK_CONSTANT_VISITED() mechanism that is used for self-referencing constants.

All tests (no opcache, opcache, JIT) pass for me locally with ASAN, so I can't comment on the CI failures.

Zend/tests/gh17711.phpt Outdated Show resolved Hide resolved
@iluuu1994
Copy link
Member Author

The failures are caused by modification of shm... I'll need to switch some things around but was too tired yesterday.

@iluuu1994 iluuu1994 force-pushed the gh-17711 branch 2 times, most recently from 1780131 to 0d31ece Compare February 6, 2025 10:42
@iluuu1994
Copy link
Member Author

I think it should be fine now. We only need to add recursion protection when the constant value is a constant AST. If it isn't, we won't attempt to evaluate it again. Recursive errors through set_error_handler are explicitly avoided by removing the error handler before triggering the error.

Copy link
Member

@TimWolla TimWolla left a comment

Choose a reason for hiding this comment

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

Still LGTM, no strong opinion on my suggestion. You're the expert.

Zend/zend_constants.c Show resolved Hide resolved
@iluuu1994 iluuu1994 marked this pull request as ready for review February 6, 2025 14:12
@iluuu1994 iluuu1994 requested a review from dstogov as a code owner February 6, 2025 14:12
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.

2 participants