-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Fix segfault in format_default_value due to unexpected enum/object #11947
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
Conversation
Evaluating constants at comptime can result in arrays that contain objects. This is problematic for printing the default value of constant ASTs containing objects, because we don't actually know what the constructor arguments were. Avoid this by not propagating array constants. Fixes phpGH-11937
Does this mean that arrays are not const evaluated any more, even if they only have scalar values? |
@Girgias It means when using a constant or class constant within a constant expression, the value from the constant won't be embedded in the outer constant anymore if it is an array. Rather, the constant is looked up and copied at runtime when evaluating the constant expression. This was previously only the case without opcache when including a file that uses a constant that has already been defined, or with preloading (I didn't test this case though). |
Ah, that doesn't sound too bad then. :) |
I guess it's probably okay. If you want to avoid some cases you could recursively check arrays for < IS_OBJECT instead, but may not be worth it. |
What I missed is that constants can also be propagated to opcode operands, which can sometimes be done even with opcache for |
The alternative didn't work easily, so I went for this solution. There was a leak reported because the object survived This solution seems more in line with the current expectations. |
Evaluating constants at comptime can result in arrays that contain objects. This is problematic for printing the default value of constant ASTs containing objects, because we don't actually know what the constructor arguments were. Avoid this by not propagating array constants.
I will need to check whether this leads to a performance regression.
Fixes GH-11937