github-vet / github-vet/rangeloop-pointer-findings

docker/buildx: commands/prune.go; 13 LoC

Open
#8,163 0 comments 0 reactions 0 assignees View on GitHub
fresh small
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [docker/buildx](https://www.github.com/docker/buildx) at [commands/prune.go](https://github.com/docker/buildx/blob/74f76cf4e9c5624113ad12523dcc23c8ef5a10af/commands/prune.go#L77-L89)

Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first
issue it finds, so please do not limit your consideration to the contents of the below message.

> function call which takes a reference to du at line 80 may start a goroutine

[Click here to see the code in its original context.](https://github.com/docker/buildx/blob/74f76cf4e9c5624113ad12523dcc23c8ef5a10af/commands/prune.go#L77-L89)

Click here to show the 13 line(s) of Go which triggered the analyzer.

```go
for du := range ch {
total += du.Size
if opts.verbose {
printVerbose(tw, []*client.UsageInfo{&du})
} else {
if first {
printTableHeader(tw)
first = false
}
printTableRow(tw, &du)
tw.Flush()
}
}

```

Click here to show extra information the analyzer produced.

```
The following dot graph describes paths through the callgraph that could lead to a function calling a goroutine:
digraph G {
"(loadMore, 0)" -> {"(Read, 1)";}
"(Print, 1)" -> {"(Info, 1)";}
"(dialWithoutProxy, 2)" -> {"(Dial, 3)";}
"(startHealthCheck, 1)" -> {}
"(newHTTP2Client, 7)" -> {"(ClientHandshake, 3)";}
"(Flush, 0)" -> {"(Write, 1)";"(close, 1)";"(Len, 0)";"(Reset, 1)";"(Bytes, 0)";"(WriteConsoleOutput, 5)";"(WriteHeader, 1)";"(WriteTo, 1)";"(Do, 1)";"(writeChunk, 1)";"(logf, 2)";}
"(GetClientConn, 2)" -> {"(getClientConn, 3)";}
"(ReadDelimited, 2)" -> {"(Read, 1)";}
"(Set, 2)" -> {"(SetMulti, 1)";"(Decode, 1)";}
"(done, 1)" -> {"(Observe, 1)";}
"(start, 0)" -> {"(UpdateState, 1)";}
"(ConfigureTransport, 1)" -> {"(configureTransport, 1)";}
"(DecompressStream, 1)" -> {"(gzipDecompress, 2)";}
"(clientHandshake, 2)" -> {"(newClientTransport, 6)";}
"(Get, 0)" -> {"(get, 1)";"(Wait, 0)";"(Decode, 3)";}
"(HcsCloseComputeSystem, 2)" -> {"(execute, 3)";}
"(RoundTripOpt, 2)" -> {"(roundTrip, 1)";"(GetClientConn, 2)";}
"(tryAllAddrs, 2)" -> {"(createTransport, 3)";}
"(wait, 1)" -> {"(Get, 3)";}
"(Info, 1)" -> {"(Get, 3)";}
"(waitingLoop, 0)" -> {"(insert, 3)";}
"(newHTTP2Server, 2)" -> {}
"(Unregister, 1)" -> {"(Describe, 1)";}
"(printVerbose, 2)" -> {"(Flush, 0)";}
"(Decode, 2)" -> {"(Read, 1)";}
"(newQueue, 3)" -> {}
"(printf, 4)" -> {"(output, 6)";}
"(PollImmediateUntil, 3)" -> {"(PollUntil, 3)";}
"(Header, 0)" -> {"(withRetry, 2)";}
"(Get, 3)" -> {}
"(HcsUnregisterProcessCallback, 2)" -> {"(execute, 3)";}
"(killIfStdioClosed, 0)" -> {"(kill, 0)";}
"(UpdateState, 1)" -> {"(poll, 1)";"(updateResolverState, 2)";}
"(dialClientConn, 2)" -> {"(newClientConn, 2)";}
"(getTransport, 3)" -> {"(pick, 3)";}
"(serveStreams, 1)" -> {"(HandleStreams, 2)";}
"(WriteTo, 1)" -> {"(Write, 1)";"(RecvMsg, 1)";}
"(Accept, 0)" -> {}
"(Marshal, 1)" -> {"(marshalDoc, 2)";}
"(WithContext, 1)" -> {"(WithCancel, 1)";}
"(resolveNow, 1)" -> {}
"(Now, 0)" -> {"(Add, 1)";}
"(Add, 1)" -> {"(unref, 0)";"(Search, 2)";}
"(refill, 0)" -> {"(Read, 1)";}
"(Infof, 2)" -> {"(printf, 4)";}
"(NewConnection, 1)" -> {"(NewClientConnection, 1)";}
"(newMux, 1)" -> {}
"(WithDeadline, 2)" -> {"(propagateCancel, 2)";}
"(CloseRead, 0)" -> {"(killIfStdioClosed, 0)";"(shutdown, 1)";}
"(newClientTransport, 6)" -> {"(kexLoop, 0)";}
"(NewUnboundedExecutor, 0)" -> {"(WithCancel, 1)";}
"(marshalDoc, 2)" -> {"(init, 0)";}
"(Observe, 1)" -> {"(asyncFlush, 1)";}
"(poller, 2)" -> {}
"(retryLocked, 1)" -> {"(newAttemptLocked, 2)";}
"(Handle, 2)" -> {"(fetchBlob, 2)";}
"(WithCancel, 1)" -> {"(propagateCancel, 2)";}
"(Serve, 1)" -> {"(checkStreamFrame, 1)";"(Push, 2)";"(handleGoAwayFrame, 1)";"(handleRawConn, 1)";"(frameHandler, 2)";}
"(Kill, 0)" -> {"(Kill, 1)";}
"(createTransport, 3)" -> {"(NewClientTransport, 7)";}
"(roundTrip, 1)" -> {"(awaitOpenSlotForRequest, 1)";"(scheduleBodyWrite, 0)";}
"(newCall, 1)" -> {"(NewContext, 1)";"(run, 1)";}
"(contextForChannel, 1)" -> {}
"(withRetry, 2)" -> {"(retryLocked, 1)";}
"(processWindowUpdate, 1)" -> {"(scheduleFrameWrite, 0)";}
"(WaitTimeout, 1)" -> {}
"(parse, 0)" -> {"(init, 0)";}
"(Negotiate, 4)" -> {"(NewConnection, 1)";}
"(Unlock, 0)" -> {"(Close, 0)";}
"(HcsUnregisterComputeSystemCallback, 2)" -> {"(execute, 3)";}
"(newClientConn, 2)" -> {"(readLoop, 0)";}
"(Start, 2)" -> {}
"(NewClientTransport, 7)" -> {"(newHTTP2Client, 7)";}
"(FromError, 1)" -> {"(New, 2)";}
"(WriteConsoleOutput, 5)" -> {"(Call, 5)";}
"(connect, 3)" -> {}
"(unregisterCallback, 1)" -> {"(HcsUnregisterComputeSystemCallback, 2)";"(HcsUnregisterProcessCallback, 2)";}
"(Kill, 1)" -> {"(processSignalResult, 2)";}
"(ClientHandshake, 3)" -> {}
"(onEOF, 1)" -> {}
"(newDelayingQueue, 3)" -> {"(waitingLoop, 0)";}
"(processHeaders, 1)" -> {"(handleResponse, 2)";}
"(Decode, 1)" -> {"(loadMore, 0)";"(ReadDelimited, 2)";"(parse, 0)";"(readValue, 0)";}
"(scheduleBodyWrite, 0)" -> {}
"(frameHandler, 2)" -> {"(handleGoAwayFrame, 1)";}
"(pipe, 0)" -> {}
"(NewClientConnection, 1)" -> {"(NewConnection, 2)";"(newConnection, 2)";}
"(Push, 2)" -> {}
"(Decode, 3)" -> {"(Decode, 2)";"(RecognizesData, 1)";}
"(output, 6)" -> {"(timeoutFlush, 1)";"(Info, 1)";}
"(LazyPrintf, 2)" -> {"(addEvent, 3)";}
"(Context, 0)" -> {"(WithCancel, 1)";}
"(processSettings, 1)" -> {"(scheduleFrameWrite, 0)";}
"(Start, 1)" -> {"(start, 0)";}
"(poll, 1)" -> {"(resolveNow, 1)";}
"(Sub, 1)" -> {"(Add, 1)";}
"(shutdown, 1)" -> {}
"(RoundTrip, 1)" -> {"(RoundTripOpt, 2)";"(Dial, 1)";"(ConnectWithRedirects, 6)";"(roundTrip, 1)";}
"(NewNamedDelayingQueue, 1)" -> {"(NewDelayingQueueWithCustomClock, 2)";}
"(Build, 2)" -> {"(Start, 2)";}
"(DialContext, 3)" -> {"(newCCResolverWrapper, 2)";"(connect, 3)";"(dialContext, 4)";"(WithCancel, 1)";}
"(logf, 2)" -> {"(Printf, 2)";}
"(getStartDialLocked, 1)" -> {}
"(updateResolverState, 2)" -> {"(applyServiceConfigAndBalancer, 2)";"(maybeApplyDefaultServiceConfig, 1)";}
"(handleRawConn, 1)" -> {"(serveStreams, 1)";"(newHTTP2Transport, 2)";}
"(Bytes, 0)" -> {"(Format, 1)";"(WriteTo, 1)";}
"(NewDelayingQueueWithCustomClock, 2)" -> {"(newDelayingQueue, 3)";}
"(switchBalancer, 1)" -> {"(newCCBalancerWrapper, 3)";}
"(List, 2)" -> {"(Walk, 3)";}
"(Describe, 1)" -> {}
"(dialContext, 4)" -> {"(Dial, 2)";}
"(awaitOpenSlotForRequest, 1)" -> {}
"(run, 3)" -> {"(Accept, 0)";}
"(close, 1)" -> {"(Close, 0)";}
"(asyncFlush, 1)" -> {}
"(connect, 0)" -> {"(resetTransport, 0)";}
"(init, 0)" -> {"(Register, 1)";}
"(NewNamedRateLimitingQueue, 2)" -> {"(NewNamedDelayingQueue, 1)";}
"(newCCResolverWrapper, 2)" -> {"(Build, 3)";}
"(Format, 1)" -> {"(NewEncoder, 1)";}
"(Printf, 2)" -> {"(Print, 1)";}
"(New, 1)" -> {"(get, 1)";"(New, 0)";}
"(Reset, 1)" -> {"(Add, 1)";}
"(get, 1)" -> {"(Observe, 1)";"(SetTransportDefaults, 1)";"(certRotatingDialer, 2)";"(Run, 1)";}
"(WriteHeader, 1)" -> {"(Encode, 1)";}
"(RecognizesData, 1)" -> {"(Read, 1)";}
"(Errorf, 2)" -> {"(printf, 4)";}
"(newAttemptLocked, 2)" -> {"(getTransport, 3)";}
"(applyServiceConfigAndBalancer, 2)" -> {"(newCCBalancerWrapper, 3)";"(switchBalancer, 1)";}
"(newConnection, 2)" -> {"(Serve, 1)";}
"(readLoop, 0)" -> {"(run, 0)";}
"(ToGRPC, 1)" -> {"(New, 2)";}
"(Register, 1)" -> {"(Describe, 1)";}
"(insert, 3)" -> {"(Push, 2)";}
"(newHTTP2Transport, 2)" -> {"(NewServerTransport, 3)";}
"(newStaticTable, 0)" -> {"(init, 0)";}
"(watcher, 0)" -> {"(UpdateSubConnState, 2)";"(HandleSubConnStateChange, 2)";}
"(New, 3)" -> {"(DialContext, 3)";"(Start, 0)";}
"(propagateCancel, 2)" -> {}
"(Start, 0)" -> {"(Start, 1)";"(Go, 1)";}
"(request, 2)" -> {"(WithTimeout, 2)";"(WithContext, 1)";}
"(NewConnection, 2)" -> {"(monitor, 0)";}
"(Walk, 3)" -> {"(Handle, 2)";}
"(NewEncoder, 1)" -> {"(init, 0)";}
"(dial, 4)" -> {}
"(getReadyTransport, 0)" -> {"(connect, 0)";}
"(New, 2)" -> {}
"(finish, 1)" -> {"(LazyPrintf, 2)";"(done, 1)";}
"(run, 1)" -> {"(Go, 1)";}
"(checkStreamFrame, 1)" -> {}
"(Encode, 1)" -> {"(marshalDoc, 2)";}
"(Info, 2)" -> {"(AddTraceEvent, 3)";"(InfoDepth, 2)";}
"(ConnectWithRedirects, 6)" -> {"(Dial, 1)";}
"(Dial, 3)" -> {"(NewClient, 3)";"(NewClientConn, 3)";}
"(resetTransport, 0)" -> {"(startHealthCheck, 1)";"(tryAllAddrs, 2)";}
"(SendMsg, 1)" -> {"(LazyLog, 2)";"(withRetry, 2)";}
"(traceEvent, 2)" -> {"(append, 1)";}
"(InfoDepth, 2)" -> {"(Info, 1)";}
"(Dial, 2)" -> {"(dial, 4)";"(dialStreamLocal, 1)";}
"(NewClient, 3)" -> {}
"(Read, 1)" -> {}
"(execute, 3)" -> {}
"(writeChunk, 1)" -> {"(Format, 1)";}
"(sanitizeLocation, 2)" -> {"(Parse, 1)";}
"(configureTransport, 1)" -> {"(addConnIfNeeded, 3)";}
"(monitor, 0)" -> {}
"(Do, 3)" -> {"(do, 3)";"(WithContext, 1)";}
"(Go, 1)" -> {}
"(New, 0)" -> {"(NewNamed, 1)";}
"(NewClientConn, 3)" -> {"(clientHandshake, 2)";"(newMux, 1)";}
"(Run, 1)" -> {"(Start, 1)";"(PollImmediateUntil, 3)";}
"(getClientConn, 3)" -> {"(getStartDialLocked, 1)";"(dialClientConn, 2)";}
"(dial, 1)" -> {"(dialWithoutProxy, 2)";"(dialClientConn, 2)";}
"(gzipDecompress, 2)" -> {"(cmdStream, 2)";}
"(Build, 3)" -> {"(start, 0)";"(UpdateState, 1)";"(ResolveNow, 1)";"(watcher, 0)";}
"(, 0)" -> {"(New, 2)";"(DialContext, 3)";"(Add, 1)";"(newStaticTable, 0)";"(NewUnboundedExecutor, 0)";"(New, 0)";"(New, 3)";"(NewSchemeBuilder, 1)";"(New, 1)";}
"(Parse, 1)" -> {"(parse, 0)";"(parseText, 1)";}
"(NewContext, 1)" -> {"(pipe, 0)";}
"(HandleSubConnStateChange, 2)" -> {"(Connect, 0)";}
"(handleResponse, 2)" -> {"(on100, 0)";}
"(Close, 0)" -> {"(HcsCloseProcess, 2)";"(Remove, 1)";"(New, 2)";"(CloseWrite, 0)";"(CloseRead, 0)";"(unregisterCallback, 1)";"(AddTraceEvent, 3)";"(shutdown, 1)";"(HcsCloseComputeSystem, 2)";"(Wait, 0)";}
"(dialStreamLocal, 1)" -> {}
"(maybeApplyDefaultServiceConfig, 1)" -> {"(applyServiceConfigAndBalancer, 2)";}
"(fetchBlob, 2)" -> {"(DecompressStream, 1)";}
"(handleGoAwayFrame, 1)" -> {}
"(RecvMsg, 1)" -> {"(Context, 0)";"(, 0)";"(New, 1)";"(LazyLog, 2)";"(FromError, 1)";"(recvMsg, 2)";"(Header, 0)";"(finish, 1)";"(withRetry, 2)";}
"(Commit, 4)" -> {"(Parse, 1)";"(Set, 2)";}
"(NewServerTransport, 3)" -> {"(newHTTP2Server, 2)";}
"(parseText, 1)" -> {"(append, 1)";}
"(Errorf, 3)" -> {"(AddTraceEvent, 3)";}
"(pick, 3)" -> {"(getReadyTransport, 0)";}
"(Search, 2)" -> {"(List, 2)";}
"(cmdStream, 2)" -> {}
"(run, 0)" -> {"(processHeaders, 1)";"(processSettings, 1)";"(processWindowUpdate, 1)";}
"(WithTimeout, 2)" -> {"(WithDeadline, 2)";}
"(Dial, 1)" -> {"(dial, 1)";"(Negotiate, 4)";}
"(SetTransportDefaults, 1)" -> {"(ConfigureTransport, 1)";}
"(append, 1)" -> {}
"(on100, 0)" -> {}
"(HandleStreams, 2)" -> {}
"(unref, 0)" -> {}
"(startFrameWrite, 1)" -> {}
"(Connect, 0)" -> {"(connect, 0)";}
"(addEvent, 3)" -> {}
"(Deregister, 1)" -> {"(Unregister, 1)";}
"(printWithFileLine, 6)" -> {"(output, 6)";}
"(recvMsg, 2)" -> {"(LazyLog, 2)";}
"(PollUntil, 3)" -> {"(contextForChannel, 1)";"(poller, 2)";}
"(LazyLog, 2)" -> {"(addEvent, 3)";}
"(kill, 0)" -> {"(killAndWait, 1)";}
"(CloseWrite, 0)" -> {"(shutdown, 1)";"(killIfStdioClosed, 0)";}
"(SetMulti, 1)" -> {"(RoundTrip, 1)";}
"(addConnIfNeeded, 3)" -> {"(run, 3)";}
"(do, 3)" -> {"(wait, 1)";"(newCall, 1)";}
"(UpdateSubConnState, 2)" -> {"(Connect, 0)";}
"(processSignalResult, 2)" -> {}
"(Remove, 1)" -> {"(Search, 2)";}
"(Write, 1)" -> {"(Error, 1)";"(Errorf, 2)";"(Errorf, 3)";"(Commit, 4)";"(sanitizeLocation, 2)";"(Close, 0)";"(Decode, 1)";"(SendMsg, 1)";"(printWithFileLine, 6)";"(Infof, 2)";"(Sub, 1)";"(onEOF, 1)";"(Wait, 0)";"(Get, 0)";"(Info, 2)";"(Set, 2)";"(Context, 0)";"(New, 1)";"(FromError, 1)";"(ToGRPC, 1)";"(RecvMsg, 1)";"(Parse, 1)";"(Marshal, 1)";"(Hash, 0)";"(Add, 1)";}
"(Call, 5)" -> {"(New, 1)";}
"(Wait, 0)" -> {"(WaitTimeout, 1)";"(Deregister, 1)";}
"(NewNamed, 1)" -> {"(newQueue, 3)";}
"(AddTraceEvent, 3)" -> {"(traceEvent, 2)";}
"(certRotatingDialer, 2)" -> {"(NewNamedRateLimitingQueue, 2)";}
"(newCCBalancerWrapper, 3)" -> {"(Build, 2)";}
"(timeoutFlush, 1)" -> {}
"(Error, 1)" -> {"(Print, 1)";}
"(NewSchemeBuilder, 1)" -> {"(Register, 1)";}
"(killAndWait, 1)" -> {"(Kill, 0)";}
"(scheduleFrameWrite, 0)" -> {"(startFrameWrite, 1)";}
"(readValue, 0)" -> {"(refill, 0)";}
"(Len, 0)" -> {"(Unlock, 0)";}
"(HcsCloseProcess, 2)" -> {"(execute, 3)";}
"(kexLoop, 0)" -> {}
"(Do, 1)" -> {"(Get, 0)";"(, 0)";"(Reset, 1)";"(Now, 0)";"(Sub, 1)";"(request, 2)";"(Close, 0)";"(Do, 3)";}
"(ResolveNow, 1)" -> {"(resolveNow, 1)";}
"(Hash, 0)" -> {"(New, 0)";}
}

```

Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.

commit ID: 74f76cf4e9c5624113ad12523dcc23c8ef5a10af

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.