syscall: replace panic with error return in Accept4 on FreeBSD#77862
Open
feizaizheli wants to merge 1 commit intogolang:masterfrom
Open
syscall: replace panic with error return in Accept4 on FreeBSD#77862feizaizheli wants to merge 1 commit intogolang:masterfrom
feizaizheli wants to merge 1 commit intogolang:masterfrom
Conversation
The Accept4 function on FreeBSD uses panic when the returned address length exceeds SizeofSockaddrAny. This is inconsistent with Go's error handling philosophy and can crash the entire program. This commit replaces the panic with proper error handling: closing the accepted file descriptor and returning EINVAL error, which allows callers to handle the exceptional case gracefully. Changes: - Close the newly accepted fd before returning error - Return EINVAL instead of panicking - Maintain consistency with other error handling in the same function If this approach is acceptable, similar changes can be applied to other platforms (NetBSD, OpenBSD, DragonflyBSD, Linux, Solaris).
Contributor
|
This PR (HEAD: 0c0cf9a) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/749922. Important tips:
|
Contributor
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/749922. |
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.
The Accept4 function on FreeBSD uses panic when the returned address length exceeds SizeofSockaddrAny. This is inconsistent with Go's error handling philosophy and can crash the entire program.
This commit replaces the panic with proper error handling: closing the accepted file descriptor and returning EINVAL error, which allows callers to handle the exceptional case gracefully.
Changes:
If this approach is acceptable, similar changes can be applied to other platforms (NetBSD, OpenBSD, DragonflyBSD, Linux, Solaris).
This PR will be imported into Gerrit with the title and first
comment (this text) used to generate the subject and body of
the Gerrit change.
Please ensure you adhere to every item in this list.
More info can be found at https://github.com/golang/go/wiki/CommitMessage
net/http: frob the quux before blarfing"This change modifies Go to ___________"
really needed (ASCII art, table, or long link)
Fixes #1234orUpdates #1234(the latter if this is not a complete fix) to this comment
golang/goyou can use theowner/repo#issue_numbersyntax:Fixes golang/tools#1234Our Gerrit server & GitHub bots enforce CLA compliance instead.