Repository navigation
Conversation
On failure, socket_addrinfo_bind(), socket_addrinfo_connect() and socket_create_listen() closed the descriptor, then destroyed the new Socket, whose destructor closed the same descriptor again. In a thread-safe build another thread could get that descriptor in between and lose it. Reset bsd_socket after the explicit close.
devnexen
approved these changes
Nov 26, 2026
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
bind(),connect()orlisten()fails,socket_addrinfo_bind(),socket_addrinfo_connect()andsocket_create_listen()close the descriptor, then destroy the newSocket, whose destructor closes the same descriptor again becausebsd_socketis never reset. In a thread-safe build, another thread can get that descriptor number in between and lose it. This resetsbsd_socketto -1 after each explicit close.To reproduce
Under
strace -e trace=close, before (PHP 8.4.28):After: a single
close(5). The added test checks that the failure paths still return false; the double close itself is only visible under strace.