multiple: fix lock management bugs and improve error handling#77848
Open
feizaizheli wants to merge 1 commit intogolang:masterfrom
Open
multiple: fix lock management bugs and improve error handling#77848feizaizheli wants to merge 1 commit intogolang:masterfrom
feizaizheli wants to merge 1 commit intogolang:masterfrom
Conversation
This commit fixes several critical bugs across multiple packages:
1. syscall: Fix incorrect defer usage in forkpipe2.go lock management
- acquireForkLock: Remove defer that causes double unlock when
hasWaitingReaders returns true. The deferred Unlock() would execute
after manual unlock/relock sequence, causing undefined behavior.
- releaseForkLock: Unlock before panic to prevent deadlock when
detecting negative forking count.
2. encoding/json: Add defensive bounds checking in stream.go
- Token(): Add len(tokenStack) == 0 check before accessing
tokenStack[len(tokenStack)-1] for both ']' and '}' delimiters.
- Prevents potential panic on malformed or concurrent access.
3. syscall: Replace panic with error return in Accept4 functions
- syscall_freebsd.go, syscall_netbsd.go, syscall_openbsd.go:
- Change panic("RawSockaddrAny too small") to return EINVAL error.
- Allows graceful error handling instead of crashing the program.
These fixes improve robustness in concurrent scenarios and abnormal
input handling, following Go's error handling best practices.
Fixes: Lock management issues in fork operations
Fixes: Potential array bounds violations in JSON parsing
Fixes: Inappropriate panic usage in syscall package
Change-Id: Ia1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0
Contributor
|
This PR (HEAD: 387ee25) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/749821. Important tips:
|
Contributor
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/749821. |
Contributor
|
Message from Keith Randall: Patch Set 2: (3 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/749821. |
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.
This commit fixes several critical bugs across multiple packages:
syscall: Fix incorrect defer usage in forkpipe2.go lock management
encoding/json: Add defensive bounds checking in stream.go
syscall: Replace panic with error return in Accept4 functions
These fixes improve robustness in concurrent scenarios and abnormal input handling, following Go's error handling best practices.
Fixes: Lock management issues in fork operations
Fixes: Potential array bounds violations in JSON parsing
Fixes: Inappropriate panic usage in syscall package
Change-Id: Ia1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0
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.