-
Notifications
You must be signed in to change notification settings - Fork 8k
Fix GH-20836: Stack overflow in mb_convert_variables with recursive array references #20839
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
base: PHP-8.4
Are you sure you want to change the base?
Fix GH-20836: Stack overflow in mb_convert_variables with recursive array references #20839
Conversation
|
This looks weird that you need to utilise both recursion protection and stack protection. Are you sure that you need both? |
|
Agree with @ndossche |
|
I added stack protection in order to have some fast path at the beginning of functions to immediately return if we can detect an error, instead of going through the whole code waiting for a recursion error to be raised |
You're optimizing the sad flow here instead of the happy flow. We generally don't do that. While here it doesn't really degrade the performance of the happy flow noticeably, it's still adding complexity. I'd prefer to stick with the recursion protection alone. |
It can be useful to differentiate between the two cases, as one of them is not supported by But changing the stack limit message emitted by |
38e60e4 to
6c7a109
Compare
|
So I pushed a new version adding a check before emitting the warning. This way, the error is displayed if the stack is overflowed and the warning is kept in case of deep/infinite recursion. Because of how the code is articulated, that's what I could achieve. |
6c7a109 to
ca26e6d
Compare
arnaud-lb
left a comment
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.
This looks right to me!
Please add tests for the stack limit case (see the SKIPIF and INI sections in https://github.com/devnexen/php-src/blob/dcdcad3ab1f83563dc2775282d73e3bc8afde828/ext/standard/tests/general_functions/gh20840.phpt).
Also maybe wait for other reviews.
ca26e6d to
b18ee3b
Compare
…e array references
b18ee3b to
bbc9c18
Compare
Fix #20836