-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed as not planned
Closed as not planned
Copy link
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.Issue is not actionable because of missing required information, which needs to be provided.
Description
Issue 1: Infinite recursion if c.cancelCtx()
Line 1651 in ad91f5d
| if c.cancelCtx != nil { |
If c.cancelCtx() panics and len(c.cleanups) > 0, the following happens:
- c.cancelCtx() panics
- The deferred function checks len(c.cleanups) > 0 → true
- Recursively calls runCleanup(normalPanic)
- c.cancelCtx is still not nil, calls c.cancelCtx() again
- Panics again → infinite recursion → stack overflow
Suggested fix:
if c.cancelCtx != nil {
cancel := c.cancelCtx
c.cancelCtx = nil // clear before calling to prevent repeated calls
cancel()
}
Issue 2: Incorrect nil check conflates empty slice with nil element
The current logic cannot distinguish between:
- Case A: c.cleanups is empty (cleanup stays default nil)
- Case B: c.cleanups contains a nil function pointer
In Case B, returning early would skip remaining cleanup functions.
Suggested fix:
for {
c.mu.Lock()
if len(c.cleanups) == 0 {
c.mu.Unlock()
return nil
}
last := len(c.cleanups) - 1
cleanup := c.cleanups[last]
c.cleanups = c.cleanups[:last]
c.mu.Unlock()
if cleanup != nil {
cleanup()
}
// continue to process remaining cleanups even if this one was nil
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.Issue is not actionable because of missing required information, which needs to be provided.