goroutineresourceleak (81st linter): paren_unwrap_gap across lock/cancel/channel detection, day one
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Start with pkg/linters/goroutineresourceleak/goroutineresourceleak.go, where line 75 already calls astutil.UnwrapParenExpr correctly. Wrap the bare assertions at lines 209, 216, 228, 322, 346, 355 and 379 the same way. Add parenthesized variants of the cancel, mutex and channel cases to testdata/src/a/a.go. Done when those testdata cases pass and the existing tests still pass.
Written by the indexing model from the issue text.
Description
Problem
pkg/linters/goroutineresourceleak (registered today via PR #68502, the 81st analyzer, registry.go confirms the delta from 80 to 81) independently reimplements lock/unlock, context-cancel, and channel send/receive/close detection rather than reusing the shared resourcetracker framework. It reproduces the long-established paren_unwrap_gap class (already filed and fixed across astutil.go, nilctxpassed, errstringmatch, sprintfbool, tolowerequalfold, timenowsub, httpstatuscode, seenmapbool, closeerrorunchecked, typeassertionnil, walkdirignoredeerror, and resourcetracker.go in prior runs) at no fewer than six call sites in one new file, pkg/linters/goroutineresourceleak/goroutineresourceleak.go:
contextCancelAcquisition(line 322): barerhs.(*ast.CallExpr).isDeferredCancel(line 346): baredeferStmt.Call.Fun.(*ast.Ident).mutexLockAcquisition(line 355): bareexprStmt.X.(*ast.CallExpr).isDeferredUnlock(line 379): baredeferStmt.Call.Fun.(*ast.SelectorExpr).markChannelUsage(lines 209, 216, 228): bare*ast.Identassertions onSendStmt.Chan, theclose()call argument, and theUnaryExpr.Xreceive operand.
Notably, the same file already imports astutil and correctly calls astutil.UnwrapParenExpr at line 75 (astutil.UnwrapParenExpr(call.Fun).(*ast.FuncLit)) for the goroutine literal itself, so the gap is an inconsistency within the file rather than a missing dependency.
Impact
Parenthesized forms are valid Go and compile identically to unparenthesized ones, for example ctx, cancel := (context.WithCancel(ctx)), defer (cancel()), (mu.Lock()), defer (mu.Unlock()), (ch) <- v, <-(ch), close((ch)). For the acquisition/defer sites, a parenthesized acquisition or deferred cleanup call means the whole per-goroutine check never engages, so a goroutine with a genuine unguarded leak using one of these forms is never reported. For the channel usage sites, a genuinely-used channel referenced once through a parenthesized identifier is treated as never sent/received/closed, producing a false-positive leak report on otherwise-correct code.
Not yet wired into .github/workflows/cgo.yml LINTER_FLAGS, so currently latent rather than CI-breaking, matching the filing bar used for prior day-one findings on new linters such as typeassertionnil and closeerrorunchecked.
Recommendation
Wrap each of the six bare type assertions with astutil.UnwrapParenExpr(...) first, consistent with the correct usage already present at line 75 of the same file.
Validation
Add parenthesized-form variants to testdata/src/a/a.go for each of the three checks (cancel, mutex, channel) to lock in the fix and prevent regression.
Effort: Medium — six call-site fixes in one file plus matching testdata.
Generated by 🤖 Sergo - Serena Go Expert · claude · agent · 375.9 AIC · ⊞ 5.2K · ◷
- expires on Oct 20, 2026, 8:01 PM UTC-08:00
- Dominant language
- Go
- Stars
- 5.4k
- Forks
- 584
- Avg merge
- 3h 20m
- Merged PRs (30d)
- 830
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from github/gh-aw
-
agent-research
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
cookie sergo
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
ai-inspected
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
automation models
Difficulty 1/5 Under an hour Newbie friendliness 1/100
Maintainers usually reply within 1 day
-
agentic-workflows automation cookie
Difficulty 5/5 Over a week Newbie friendliness 1/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
ViewData can pair the in-flight proposal with the prepared flag of another proposalPossibly taken @HagarMeir claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
hyperledger/SmartBFT#710 ·
Maintainers usually reply within 1 day
-
agent-butler-finding chore
Difficulty 1/5 Under an hour Newbie friendliness 90/100
jordansmall/spindrift#5575 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
open-telemetry/opentelemetry-go-compile-instrumentation#1512 ·
Maintainers usually reply within 3 days
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
OpenPrinting/go-mfp#124 ·
Maintainers usually reply within 1 day