fix(thread-channel): a refused value never reaches the buffer - #227
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
EdmondDantes
force-pushed
the
fix/thread-channel-refused-value
branch
from
August 13, 2026 16:44
044cc23 to
58aff00
Compare
EdmondDantes
force-pushed
the
fix/thread-channel-refused-value
branch
from
August 13, 2026 18:02
58aff00 to
6cd7ab3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
ThreadChannel::send()transfers its argument into persistent memory before it takes the lock. The transfer refuses what it cannot copy — a resource, an object with dynamic properties — by releasing the partial graph, leaving the destinationIS_UNDEFand throwing. The send did not check for that: it pushed the undefined slot into the buffer and returned true, so the caller got the right exception while the buffer held a value no receiver can interpret.ThreadPoolreads a task as an array, so the next worker to pop that slot died onZEND_ASSERT(Z_TYPE(task) == IS_ARRAY)atthread_pool.c:347. In a release build the assertion is compiled out and the array fields are read from a value that is not an array.The send now leaves the buffer untouched and returns false. Every caller already handles that:
ThreadChannel::send()rethrows the pending exception, andThreadPool::submit()andmap()release the snapshot, the shared state and the remote future before reporting —thread_pool_throw_closed()keeps a pending exception rather than replacing it, so the transfer error is what the caller sees.Reproduction
Before: the message is printed and the process aborts (exit 134). After: the message is printed and the process exits 0.
Tests
tests/thread_channel/045-send_refused_value_not_buffered.phptcovers the refusal, the untouched buffer and a following send that succeeds. It fails onmainand passes with the fix.tests/thread_channel,tests/thread_poolandtests/channel— 199 tests, 0 failed. The full suite is unchanged at 3 pre-existing failures intests/curlandtests/io, which fail identically without this change.