goroutineresourceleak: checkChannelLeak misses usage via function-call indirection (channel_usage_indirection_blind)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 72/100
Línea de trabajo
Lee pkg/linters/goroutineresourceleak/goroutineresourceleak.go, centrándote en checkChannelLeak y markChannelUsage; después, revisa los SAFE PATTERNS en testdata/src/a/a.go, alrededor de las líneas 259-318. Añade el caso de prueba descrito para una llamada a una función auxiliar y amplía el análisis de uso para que un canal pasado a una función auxiliar no se notifique como una fuga. El trabajo estará terminado cuando pase el nuevo caso y los casos positivos y negativos existentes enumerados conserven su comportamiento.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Problem
pkg/linters/goroutineresourceleak/goroutineresourceleak.go checkChannelLeak (lines 149-171), backed by createdChannels and markChannelUsage (lines 173-236), only recognizes a channel as used inside a spawned goroutine via three direct AST shapes within the goroutine body itself: a SendStmt (ch <- v), a literal close(ch) call, or a unary receive (<-ch). There is no handling for a channel being passed as an argument to another function call, stored into a struct field or closure, or returned -- all common decomposition patterns where the real send/receive/close happens inside the callee rather than inline in the goroutine body.
This causes a false-positive channel leak report on perfectly safe code: a goroutine that creates a channel and immediately hands it off to a well-behaved helper function (for example go func() { ch := make(chan int); process(ch) }(), where process does the actual send/receive/close) has zero recognized usage events under the current scan, so it falls through every safe-pattern check in checkChannelLeak and gets flagged as a leak.
Evidence
- goroutineresourceleak.go:159-160 -- channels := createdChannels(pass, body); markChannelUsage(pass, body, channels), both walk only the goroutine's own body via ast.Inspect (excluding FuncLit boundaries)
- goroutineresourceleak.go:208-233 -- markChannelUsage checks only *ast.SendStmt, a close(...) CallExpr, and a token.ARROW UnaryExpr; no case handles a channel identifier appearing as a plain CallExpr argument, a composite literal field, or a return value
- testdata/src/a/a.go:259-318 (SAFE PATTERNS section) has zero coverage for a channel passed to a helper function -- every existing safe case either uses one of the three recognized syntactic forms directly inline, or is a named-function goroutine (go doSomeWork()), which is explicitly out of scope for the whole check per the namedFunctionGoroutine comment
- This is distinct from the already-filed paren_unwrap_gap (#68591) and adjacent_defer_assumption (#68945) issues on this same linter, which affect checkCancelLeak/checkMutexLeak rather than checkChannelLeak
Recommendation
Extend markChannelUsage to also treat a channel identifier appearing as a CallExpr argument (or in a composite literal / return statement) as a usage event, at least conservatively marking it as both sent-and-received to suppress the diagnostic -- a full call-graph analysis is out of scope for an AST-heuristic linter, but a channel handed to any opaque call should not be treated as provably unused.
Validation checklist
- Add a testdata case: ch := make(chan int); process(ch) where process is an external/unanalyzed function -- should NOT be flagged
- Confirm existing positive cases (channelWithoutUse, channelWithSend, channelWithReceive, channelWithUnbufferedSequentialSendAndReceive) still correctly flag
- Confirm existing negative cases (channelWithClose, channelWithBufferedSendAndReceive) still correctly pass
Effort
Small -- one function (markChannelUsage) plus one new testdata fixture.
Pattern class: channel_usage_indirection_blind (new -- a resource-usage scan recognizing only a closed set of direct syntactic forms, with no awareness of usage via a function-call indirection).
Generated by 🤖 Sergo - Serena Go Expert · claude · agent · 211.8 AIC · ⌖ 0.49 AIC · ⊞ 5.3K · ◷
- expires on Oct 23, 2026, 7:59 PM UTC-08:00
- Lenguaje dominante
- Go
- Estrellas
- 5.4k
- Forks
- 584
- Merge medio
- 3 h 20 min
- PR fusionados (30 d)
- 830
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de github/gh-aw
-
agent-research
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
automated conformance medium-priority safe-outputs
Dificultad 1/5 Menos de una hora Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
windows workflow
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
MCP Gateway rejects digest-pinned container images: embedded JSON schema disagrees with containerPatternPosiblemente ocupada @pelikhan la tomó hoy. Abiertoai-inspected
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
goroutineresourceleak (81st linter): paren_unwrap_gap across lock/cancel/channel detection, day oneAbiertocookie sergo
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
github/gh-aw#68591 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de github/gh-aw
Issues similares
-
Chained slog With calls discard previously bound attributesPosiblemente ocupada @yuefdev la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
[scanner] TestAgentNowLineStates hard-fails instead of degrading when node is off PATHPosiblemente ocupada @arteeh la tomó hoy. Abiertoagent/scanner ci help wanted kind/test
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
hivecommons/hive#12924 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Gentleman-Programming/engram#1940 ·
Los mantenedores suelen responder en 1 día
-
area: go-workers help wanted tech debt
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
[exporter/splunkhec] Oversized metric event causes subsequent valid metrics to be droppedPosiblemente ocupada @harshkoli1255 la tomó hoy. Abiertobug exporter/splunkhec needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
open-telemetry/opentelemetry-collector-contrib#52142 · 1 comentario ·
Los mantenedores suelen responder en 1 día