Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/rpc: methods without reply never returns #65190

Closed
sloonz opened this issue Jan 21, 2024 · 1 comment
Closed

net/rpc: methods without reply never returns #65190

sloonz opened this issue Jan 21, 2024 · 1 comment

Comments

@sloonz
Copy link

sloonz commented Jan 21, 2024

Go version

go version go1.21.5 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/sloonz/.cache/go-build'
GOENV='/home/sloonz/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/sloonz/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/sloonz/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.5'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build916148087=/tmp/go-build -gno-record-gcc-switches'

What did you do?

I’m using net/rpc to do some RPC. One of the methods returns nothing, which I have (naively) implemented like this :

// Server
func (s *Service) DoSomething(args *Args, reply *any) error {
  doSomething(args)
  return nil
}

// Client
client.Call("Service.DoSomething", Args{}, nil)

While I get no error, client.Call() never returns. I can reproduce the issue in a standalone playground : https://go.dev/play/p/P8igTsGuldg (which interestingly detects a deadlock once it’s a single-process setup)

Some variants: replacing any by interface{} and setting *reply = nil results in the same issue ; replacing any with struct{} and not setting reply works correctly.

What did you see happen?

In my origin setup (where it was cross-process), I just saw client.Call() never returning. On playground (single-process setup), interestingly, the deadlock detectors kick-in and gives a trace : log.txt

What did you expect to see?

Either that usage is incorrect, and an error should be thrown at some point instead of just silently hanging. Or the documentation should maybe mention it. Or that usage is correct and it’s a bug — I can’t tell at this point.

@seankhliao
Copy link
Member

From encoding/gob:

Nil pointers are not permitted, as they have no value.

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants