Skip to content

Fix fiber switch corrupting user comparator globals in sort functions - #24426

Open
lacatoire wants to merge 1 commit into
php:masterfrom
lacatoire:fix/sort-comparator-fiber-switch-upstream
Open

lacatoire wants to merge 1 commit into
php:masterfrom
lacatoire:fix/sort-comparator-fiber-switch-upstream

Conversation

@lacatoire

Copy link
Copy Markdown
Member

usort(), uasort(), uksort(), array_multisort() and the user-callback array_diff()/array_intersect() variants save and restore a request-global comparator in LIFO order. A comparator that suspends a Fiber lets another fiber's sort overwrite it, so the restore writes back a stale pointer (wrong comparator, or a segfault in array_multisort()).

Block fiber switching while the global is live. Suspending from the comparator now throws a FiberError.

usort(), uasort(), uksort(), array_multisort() and the user-callback
array_diff()/array_intersect() variants save and restore a request-global
comparator in LIFO order. A comparator that suspends a Fiber lets another
fiber's sort overwrite it, so the restore writes back a stale pointer
(wrong comparator, or a segfault in array_multisort()).

Block fiber switching while the global is live. Suspending from the
comparator now throws a FiberError.
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.

1 participant