Fix for crash with references on PHP7 #113
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This solves #94.
I've turned the example in the issue into a test for the issue and added a workaround which passes the test.
It's likely there's a better solution for this, but we were seeing this problem in production so making the symptoms go away needed to be done urgently.
I would expect this change to introduce a memory leak, but after running for a couple of days on our high-traffic php-fpm backend I'm not seeing much of that. Obviously ymmv.
I've managed to trace the issue to the zval of
$bad[1]
getting corrupted after$bad[10]
is parsed.$bad[1]
turns into anIS_INDIRECT
pointing to anIS_REFERENCE
, pointing to an array. The second element array ($bad[10]
) does not turn into an indirect and is merely a reference to an array.This corruption doesn't occur when I exempt
IS_INDIRECT
zvals inmsgpack_var_replace
.I'm hoping this either suffices as a fix or points someone with more experience with these internals to the 'proper' solution.
(Note the build for this pull fails due to master currently failing 041.phpt, which is fixed by #109 )