Skip to content

Conversation

@alexandre-daubois
Copy link
Member

@alexandre-daubois alexandre-daubois commented Jan 5, 2026

Fix #20836

@ndossche
Copy link
Member

ndossche commented Jan 5, 2026

This looks weird that you need to utilise both recursion protection and stack protection. Are you sure that you need both?

@alexdowad
Copy link
Contributor

Agree with @ndossche

@alexandre-daubois
Copy link
Member Author

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

@ndossche
Copy link
Member

ndossche commented Jan 6, 2026

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.

@arnaud-lb
Copy link
Member

both recursion protection and stack protection

It can be useful to differentiate between the two cases, as one of them is not supported by mb_convert_variables(), while the other is supported as long as the stack is large enough. So a "Cannot handle recursive references" tells you that you can not use mb_convert_variables() like that, while "Maximum call stack size reached" tells you that you may be able to fix the problem by increasing the stack size.

But changing the stack limit message emitted by mb_convert_variables() so that it mentions potential recursive references would work too, I think: "Maximum call stack size reached. Deeply nested structure or recursive references?".

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.

Stack overflow in mbstring variable conversion with recursive array references

4 participants