Skip to content

Infinite recursion through deprecated class constants self-referencing through deprecation message #17711

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
iluuu1994 opened this issue Feb 5, 2025 · 0 comments

Comments

@iluuu1994
Copy link
Member

Description

The following code:

<?php

const TEST = 'Message';

class C {
    #[\Deprecated(self::C)]
    const C = TEST;
}

var_dump(C::C);

Resulted in this output:

Segfault

But I expected this output instead:

Deprecated constant C::C
string(7) "Message"

PHP Version

PHP 8.4

Operating System

No response

@iluuu1994 iluuu1994 self-assigned this Feb 5, 2025
iluuu1994 added a commit to iluuu1994/php-src that referenced this issue Feb 5, 2025
iluuu1994 added a commit to iluuu1994/php-src that referenced this issue Feb 5, 2025
iluuu1994 added a commit to iluuu1994/php-src that referenced this issue Feb 5, 2025
iluuu1994 added a commit to iluuu1994/php-src that referenced this issue Feb 6, 2025
iluuu1994 added a commit to iluuu1994/php-src that referenced this issue Feb 6, 2025
iluuu1994 added a commit to iluuu1994/php-src that referenced this issue Feb 6, 2025
iluuu1994 added a commit to iluuu1994/php-src that referenced this issue Mar 25, 2025
iluuu1994 added a commit to iluuu1994/php-src that referenced this issue Mar 26, 2025
DanielEScherzer added a commit to DanielEScherzer/php-src that referenced this issue Apr 30, 2025
Add recursion protection when emitting deprecation warnings for class
constants, since the deprecation message can come from an attribute that is
using the same constant for the message, or otherwise result in recursion.

But, internal constants are persisted, and thus cannot have recursion
protection. Otherwise, if a user error handler triggers bailout before the
recursion flag is removed then a subsequent request (e.g. with `--repeat 2`)
would start with that flag already applied. Internal constants can presumably
be trusted not to use deprecation messages that come from recursive attributes.

Fixes phpGH-18463
Fixes phpGH-17711
DanielEScherzer added a commit to DanielEScherzer/php-src that referenced this issue May 3, 2025
Add recursion protection when emitting deprecation warnings for class
constants, since the deprecation message can come from an attribute that is
using the same constant for the message, or otherwise result in recursion.

But, internal constants are persisted, and thus cannot have recursion
protection. Otherwise, if a user error handler triggers bailout before the
recursion flag is removed then a subsequent request (e.g. with `--repeat 2`)
would start with that flag already applied. Internal constants can presumably
be trusted not to use deprecation messages that come from recursive attributes.

Fixes phpGH-18463
Fixes phpGH-17711
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant