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/http: GET request hangs in Linux forked process exported via Cgo shared library #47468

Closed
avnileshshinde opened this issue Jul 30, 2021 · 1 comment

Comments

@avnileshshinde
Copy link

avnileshshinde commented Jul 30, 2021

What version of Go are you using (go version)?

$ go version
version go1.16.4 linux/386

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
$ go env
GO111MODULE=""
GOARCH="386"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="386"
GOHOSTOS="linux"
GOINSECURE="golang.org,googlesource.com"
GOMODCACHE="/home/nilesh/golang/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/nilesh/golang"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_386"
GOVCS=""
GOVERSION="go1.16.4"
GCCGO="gccgo"
GO386="sse2"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/nilesh/SVN/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m32 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build718813889=/tmp/go-build -gno-record-gcc-switches"

What did you do?

See Go definition of CheckConnection() function attached in Sample.zip. I exported CheckConnection Go function as C function in .so file using following command. This function makes http GET request to google.com using http.client.

 go build -o libapp.so -buildmode=c-shared libapp.go

Then using generated .SO and .h, called exported Go function from my C test program. Below is the command I used to compile and build my C test program.

 gcc -m32 -o ctest ctest.c ./libapp.so

In the C test program, I called exported CheckConnection() function from main() and from forked process. Function call from main() gets succeeded whereas function call from forked process hangs at

  res,err := myClient.Get("https://www.google.com")

Attached is the sample code reproducible. [(Sample.zip)]
Sample.zip

What did you expect to see?

Both calls to CheckConnection() should succeed.

What did you see instead?

CheckConnection() call from main() succeed and CheckConnection() call from forked process hangs.

@odeke-em odeke-em changed the title http.client GET request hangs in Linux forked process exported via Cgo shared library net/http: GET request hangs in Linux forked process exported via Cgo shared library Jul 31, 2021
@seankhliao
Copy link
Member

Duplicate of #15538

@seankhliao seankhliao marked this as a duplicate of #15538 Aug 1, 2021
@golang golang locked and limited conversation to collaborators Aug 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants