You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ran NilAway on some code of ours, and got a few messages to this effect:
broadcast_receiver.go:66:10: error: Potential nil panic detected. Observed nil flow from source to dereference point:
-> context/context.go:184:9: literal `nil` returned from `Done()` in position 0
-> context/context.go:105:2: returned as result 0 from interface method `Context.Done()` (implemented by `emptyCtx.Done()`)
-> broadcast_receiver.go:66:10: result 0 of `Done()` uninitialized; nil channel accessed****
The code in question is selecting on .Done() for a context. That context is created as such:
for {
select {
case <-b.ctx.Done():
return
... more cases here...
}
}
While it is true that context.Background() creates an emptyCtx, that which can return a nil channel, when wrapping that emptyCtx with context.WithCancel, the resulting context is replaced with a cancelCtx, cancels being propagated (needlessly) to the emptyCtx, with cancelCtx not returning a nil channel.
This to me suggests this is a false positive.
The text was updated successfully, but these errors were encountered:
Thanks for reporting such cases! We were aware of this issue (generally channels are not handled gracefully for now) and are brewing some PRs for a fix.
Closing this issue as a duplicate of #98, let's continue the discussion there!
Ran NilAway on some code of ours, and got a few messages to this effect:
The code in question is selecting on
.Done()
for acontext
. That context is created as such:Said selection happening in a separate function:
While it is true that
context.Background()
creates anemptyCtx
, that which can return a nil channel, when wrapping thatemptyCtx
withcontext.WithCancel
, the resulting context is replaced with acancelCtx
, cancels being propagated (needlessly) to the emptyCtx, with cancelCtx not returning a nil channel.This to me suggests this is a false positive.
The text was updated successfully, but these errors were encountered: