Repository navigation
socket_accept() returning a freed Socket when its operation throws - #7
Merged
bukka merged 1 commit intoOct 13, 2026
Merged
Conversation
The new Socket was released and left in return_value, so the caller released it a second time.
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.
When the accept operation fails with an exception (a provider's
run()throws, or a scheduler cancels the coroutine waiting insocket_accept()),socket_accept()releases the newSocketand returns throughRETURN_THROWS()with that object still inreturn_value. The caller releases it a second time: an assertion failure inzend_objects_store_del()on a debug and an ASAN build (a double free on a release build, read from the code, not run).Reproduction (debug build,
ext/sockets):Expected:
cancelled. Actual:Assertion ... failedinzend_objects_store_del().The exception path now clears
return_valueafter the release, aszend_builtin_functions.cdoes before itsRETURN_THROWS().Tests
ext/sockets/tests/socket_io_hooks_accept_throws.phpt: the reproduction above, with the operation's class in the message.It fails without the fix and passes with it;
ext/sockets/tests: 106 passed, 0 failed, on a debug and an ASAN build (ZTS, Linux, io_uring), this commit on TrueAsync's coreasync-core-io-2026-10-09-3, which carriesio_hooks_poc566a683;socket_accept()is the same on 8e470c2.