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

runtime: segmentation violation with linkshared #44117

Closed
ManojKumarChauhan opened this issue Feb 5, 2021 · 11 comments
Closed

runtime: segmentation violation with linkshared #44117

ManojKumarChauhan opened this issue Feb 5, 2021 · 11 comments

Comments

@ManojKumarChauhan
Copy link

@ManojKumarChauhan ManojKumarChauhan commented Feb 5, 2021

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

$ go version
go version go1.15.1 linux/amd64

Does this issue reproduce with the latest release?

Yes with every version

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

Linux 16.04.1-Ubuntu x86_64 GNU/Linux

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

What did you do?

Dev Machine: Created a http application with linkshared option
go install -buildmode=shared runtime sync/atomic
go build -linkshared hpptapp.go

source code for httpapp.go

package main

import (
    "github.com/labstack/echo"
    "net/http"
)

func mainAdmin(c echo.Context) error {
    client := &http.Client{}
    req, err := http.NewRequest("GET", "https://www.geeksforgeeks.org/find-triplets-array-whose-sum-equal-zero", nil)

    if err == nil {
        resp, err2 := client.Do(req)
        if err2 == nil {
            defer resp.Body.Close()
        }
   }
    return c.String(http.StatusOK, "Hello, Main!")
}

func main() {
    e := echo.New()
    e.GET("/main", mainAdmin)
    e.Start(":1328")
}

Copied the app (hpptapp) with its dependent libraries (go-runtime) and run on another machine (Linux 16.04.1) where Golang is not installed. Launch the app & hit the browser(localhost:1328/main) multiple times, it worked as expected (print Hello, Main! in browser window). Again hit the browser after few seconds the app crashed. The crash can be reproduce every time. After launching the application, wait for few seconds. The crash can be reproduce easily on any machine where golang is not installed.

What did you expect to see?

The application should not crash.

What did you see instead?

It is getting crashed in ‘client.Do’ function. I am getting following stack trace

unexpected fault address 0x154ce0
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x1 addr=0x154ce0 pc=0x154ce0]

goroutine 31 [running]:
runtime.throw(0x7f03b0b95f77, 0x5)
/usr/local/go/src/runtime/panic.go:1116 +0x74 fp=0xc0000ce518 sp=0xc0000ce4e8 pc=0x7f03b0b4b494
runtime.sigpanic()
/usr/local/go/src/runtime/signal_unix.go:727 +0x428 fp=0xc0000ce548 sp=0xc0000ce518 pc=0x7f03b0b68a88
crypto/sha512.blockAMD64(0xc0000ce778, 0xc0000ce7b8, 0x80, 0x80)
/usr/local/go/src/crypto/sha512/sha512block_amd64.s:144 +0x3f15 fp=0xc0000ce550 sp=0xc0000ce548 pc=0x654315
crypto/sha512.block(0xc0000ce778, 0xc0000ce7b8, 0x80, 0x80)
/usr/local/go/src/crypto/sha512/sha512block_amd64.go:23 +0x8e fp=0xc0000ce580 sp=0xc0000ce550 pc=0x6503ae
crypto/sha512.(*digest).Write(0xc0000ce778, 0xc0000ce650, 0x10, 0x80, 0x62, 0x0, 0x0)
/usr/local/go/src/crypto/sha512/sha512.go:262 +0x1df fp=0xc0000ce5d0 sp=0xc0000ce580 pc=0x64fa5f
crypto/sha512.(*digest).checkSum(0xc0000ce778, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/crypto/sha512/sha512.go:310 +0x125 fp=0xc0000ce6e0 sp=0xc0000ce5d0 pc=0x650085
crypto/sha512.(*digest).Sum(0xc000542d20, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0)
/usr/local/go/src/crypto/sha512/sha512.go:282 +0xa5 fp=0xc0000ce868 sp=0xc0000ce6e0 pc=0x64fba5
crypto/hmac.(*hmac).Sum(0xc000541c80, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0)
/usr/local/go/src/crypto/hmac/hmac.go:57 +0x58 fp=0xc0000ce8b8 sp=0xc0000ce868 pc=0x6814b8
golang.org/x/crypto/hkdf.(*hkdf).Read(0xc00050caf0, 0xc00052f340, 0x20, 0x20, 0xc0000a2770, 0xd, 0x10)
/usr/local/go/src/golang.org/x/crypto/hkdf/hkdf.go:63 +0x1d3 fp=0xc0000ce918 sp=0xc0000ce8b8 pc=0x71fb53
crypto/tls.(*cipherSuiteTLS13).expandLabel(0xd32fe0, 0xc00025c240, 0x30, 0x30, 0x88a498, 0x3, 0x0, 0x0, 0x0, 0x20, …)
/usr/local/go/src/crypto/tls/key_schedule.go:46 +0x2a2 fp=0xc0000cea30 sp=0xc0000ce918 pc=0x754b02
crypto/tls.(*cipherSuiteTLS13).trafficKey(0xd32fe0, 0xc00025c240, 0x30, 0x30, 0x30, 0x30, 0x30, 0xc00025c240, 0x30, 0x30)
/usr/local/go/src/crypto/tls/key_schedule.go:77 +0x98 fp=0xc0000ceac0 sp=0xc0000cea30 pc=0x755218
crypto/tls.(*halfConn).setTrafficSecret(0xc0000fe1f0, 0xd32fe0, 0xc00025c240, 0x30, 0x30)
/usr/local/go/src/crypto/tls/conn.go:215 +0x7a fp=0xc0000ceb20 sp=0xc0000ceac0 pc=0x7281da
crypto/tls.(*clientHandshakeStateTLS13).establishHandshakeKeys(0xc0000cedf0, 0x0, 0x0)
/usr/local/go/src/crypto/tls/handshake_client_tls13.go:360 +0x226 fp=0xc0000cec00 sp=0xc0000ceb20 pc=0x73b046
crypto/tls.(*clientHandshakeStateTLS13).handshake(0xc0000cedf0, 0xc0000a2668, 0x4)
/usr/local/go/src/crypto/tls/handshake_client_tls13.go:79 +0x1bb fp=0xc0000cec50 sp=0xc0000cec00 pc=0x73943b
crypto/tls.(*Conn).clientHandshake(0xc0000fe000, 0x0, 0x0)
/usr/local/go/src/crypto/tls/handshake_client.go:209 +0x65d fp=0xc0000ceee0 sp=0xc0000cec50 pc=0x732f5d
crypto/tls.(*Conn).clientHandshake-fm(0x0, 0x0)
/usr/local/go/src/crypto/tls/handshake_client.go:136 +0x2c fp=0xc0000cef08 sp=0xc0000ceee0 pc=0x76e98c
crypto/tls.(*Conn).Handshake(0xc0000fe000, 0x0, 0x0)
/usr/local/go/src/crypto/tls/conn.go:1362 +0xc9 fp=0xc0000cef78 sp=0xc0000cef08 pc=0x731049
net/http.(*persistConn).addTLS.func2(0x0, 0xc0000fe000, 0xc00051f8b0, 0xc000540ea0)
/usr/local/go/src/net/http/transport.go:1509 +0x45 fp=0xc0000cefc0 sp=0xc0000cef78 pc=0x819545
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1374 +0x1 fp=0xc0000cefc8 sp=0xc0000cefc0 pc=0x7f03b0b8cfc1
created by net/http.(*persistConn).addTLS
/usr/local/go/src/net/http/transport.go:1505 +0x17d

goroutine 1 [IO wait]:
internal/poll.runtime_pollWait(0x7f03b0f0df48, 0x72, 0x0)
/usr/local/go/src/runtime/netpoll.go:220 +0x65
internal/poll.(*pollDesc).wait(0xc00014c318, 0x72, 0x0, 0x0, 0x88b2eb)
/usr/local/go/src/internal/poll/fd_poll_runtime.go:87 +0x47
internal/poll.(*pollDesc).waitRead(…)
/usr/local/go/src/internal/poll/fd_poll_runtime.go:92
internal/poll.(*FD).Accept(0xc00014c300, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/internal/poll/fd_unix.go:394 +0x1fc
net.(*netFD).accept(0xc00014c300, 0x1, 0x203000, 0x203000)
/usr/local/go/src/net/fd_unix.go:172 +0x45
net.(*TCPListener).accept(0xc00000e680, 0x29e8d60800, 0x8dffb4, 0xc0000d1d58)
/usr/local/go/src/net/tcpsock_posix.go:139 +0x34
net.(*TCPListener).AcceptTCP(0xc00000e680, 0xca1d52c7009746b2, 0x0, 0x0)
/usr/local/go/src/net/tcpsock.go:248 +0x67
github.com/labstack/echo.tcpKeepAliveListener.Accept(0xc00000e680, 0xc0000d1d58, 0x5ad9c8,   0x601400dd, 0x7f03b0b58970)
/root/go/src/github.com/labstack/echo/echo.go:946 +0x31
net/http.(*Server).Serve(0xc00014e000, 0xba22c0, 0xc00003ec98, 0x0, 0x0)
/usr/local/go/src/net/http/server.go:2937 +0x286
github.com/labstack/echo.(*Echo).serve(0xc000150000, 0xc00014e000, 0x0)
/root/go/src/github.com/labstack/echo/echo.go:789 +0x9b
github.com/labstack/echo.(*Echo).Start(0xc000150000, 0x88a92b, 0x5, 0xb92858, 0x0)
/root/go/src/github.com/labstack/echo/echo.go:663 +0xd7
main.main()
/root/go/src/http2.go:66 +0x10f

goroutine 23 [IO wait]:
internal/poll.runtime_pollWait(0x7f03b0f0dca8, 0x72, 0xb9d200)
/usr/local/go/src/runtime/netpoll.go:220 +0x65
internal/poll.(*pollDesc).wait(0xc000520a18, 0x72, 0xc000539100, 0x1, 0x1)
/usr/local/go/src/internal/poll/fd_poll_runtime.go:87 +0x47
internal/poll.(*pollDesc).waitRead(…)
/usr/local/go/src/internal/poll/fd_poll_runtime.go:92
internal/poll.(*FD).Read(0xc000520a00, 0xc000539151, 0x1, 0x1, 0x0, 0x0, 0x0)
/usr/local/go/src/internal/poll/fd_unix.go:159 +0x1b1
net.(*netFD).Read(0xc000520a00, 0xc000539151, 0x1, 0x1, 0x0, 0x0, 0x0)
/usr/local/go/src/net/fd_posix.go:55 +0x51
net.(*conn).Read(0xc00003e050, 0xc000539151, 0x1, 0x1, 0x0, 0x0, 0x0)
/usr/local/go/src/net/net.go:182 +0x90
net/http.(*connReader).backgroundRead(0xc000539140)
/usr/local/go/src/net/http/server.go:690 +0x5a
created by net/http.(*connReader).startBackgroundRead
/usr/local/go/src/net/http/server.go:686 +0xd5

goroutine 25 [chan receive]:
net/http.(*persistConn).addTLS(0xc00053c480, 0xc00052ef40, 0x15, 0x0, 0xc00052ef56, 0x3)
/usr/local/go/src/net/http/transport.go:1515 +0x1a6
net/http.(*Transport).dialConn(0xd38ee0, 0xba3300, 0xc0000a20a8, 0x0, 0x89ad45, 0x5,    0xc00052ef40, 0x19, 0x0, 0xc00053c480, …)
/usr/local/go/src/net/http/transport.go:1585 +0x1d67
net/http.(*Transport).dialConnFor(0xd38ee0, 0xc0001c4160)
/usr/local/go/src/net/http/transport.go:1421 +0xc8
created by net/http.(*Transport).queueForDial
/usr/local/go/src/net/http/transport.go:1390 +0x42f

goroutine 22 [select]:
net/http.(*Transport).getConn(0xd38ee0, 0xc000361400, 0x0, 0x89ad45, 0x5, 0xc00052ef40, 0x19, 0x0, 0x0, 0x0, …)
/usr/local/go/src/net/http/transport.go:1347 +0x5a9
net/http.(*Transport).roundTrip(0xd38ee0, 0xc000172900, 0x30, 0xc000539290, 0x7f03877f32f8)
/usr/local/go/src/net/http/transport.go:569 +0x78e
net/http.(*Transport).RoundTrip(0xd38ee0, 0xc000172900, 0xd38ee0, 0x0, 0x0)
/usr/local/go/src/net/http/roundtrip.go:17 +0x37
net/http.send(0xc000172900, 0xb9c2a0, 0xd38ee0, 0x0, 0x0, 0x0, 0xc00003e060, 0x8e0104, 0x1, 0x0)
/usr/local/go/src/net/http/client.go:252 +0x45a
net/http.(*Client).send(0xc000539230, 0xc000172900, 0x0, 0x0, 0x0, 0xc00003e060, 0x0, 0x1, 0xc0000ce850)
/usr/local/go/src/net/http/client.go:176 +0xff
net/http.(*Client).do(0xc000539230, 0xc000172900, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/client.go:718 +0x46f
net/http.(*Client).Do(0xc000539230, 0xc000172900, 0x89ad45, 0x46, 0x0)
/usr/local/go/src/net/http/client.go:586 +0x37
main.mainAdmin(0xba7380, 0xc00011cf00, 0x0, 0x0)
/root/go/src/http2.go:35 +0x1f7
github.com/labstack/echo.(*Echo).add.func1(0xba7380, 0xc00011cf00, 0x0, 0x0)
/root/go/src/github.com/labstack/echo/echo.go:536 +0x64
github.com/labstack/echo.(*Echo).ServeHTTP(0xc000150000, 0xba2980, 0xc00014e2a0, 0xc000172800)
/root/go/src/github.com/labstack/echo/echo.go:646 +0x187
net/http.serverHandler.ServeHTTP(0xc00014e000, 0xba2980, 0xc00014e2a0, 0xc000172800)
/usr/local/go/src/net/http/server.go:2843 +0xa5
net/http.(*conn).serve(0xc000423ea0, 0xba32c0, 0xc000361340)
/usr/local/go/src/net/http/server.go:1925 +0x8b1
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2969 +0x394
@seankhliao seankhliao changed the title Go Application is crashing for http runtime: crash when built with linkmode=shared Feb 5, 2021
@seankhliao seankhliao changed the title runtime: crash when built with linkmode=shared runtime: crash when built with linkshared Feb 5, 2021
@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented Feb 5, 2021

can you please include the exact steps to reproduce this? because this works:

FROM golang:1.15-buster AS build
WORKDIR /go/src/example.com/app
RUN go install -x -buildmode=shared runtime sync/atomic
COPY httpapp.go .
RUN go get . && go build -linkshared


FROM ubuntu:16.04
WORKDIR /app
COPY --from=build /usr/local/go/pkg/linux_amd64_dynlink /usr/local/go/pkg/linux_amd64_dynlink
COPY --from=build /go/src/example.com/app/app .
ENTRYPOINT /app/app

Loading

@ManojKumarChauhan
Copy link
Author

@ManojKumarChauhan ManojKumarChauhan commented Feb 5, 2021

goappcrashed

dev machine logs

root@manoj:~/go/src# go install -x -buildmode=shared runtime sync/atomic
WORK=/tmp/go-build658554949
mkdir -p $WORK/b008/
mkdir -p /usr/local/go/pkg/linux_amd64_dynlink/sync/
cp /root/.cache/go-build/44/44a830c1ea71fd2218acb315ff1acd029f9d81ba6f16f06bf6237a8b7ae0f613-d /usr/local/go/pkg/linux_amd64_dynlink/sync/atomic.a
rm -r $WORK/b008/
mkdir -p $WORK/b010/
mkdir -p /usr/local/go/pkg/linux_amd64_dynlink/runtime/
cp /root/.cache/go-build/4e/4e01ad880e0029062709d308472148593bdfa5e268d50fcc617b9b387a30fc47-d /usr/local/go/pkg/linux_amd64_dynlink/runtime/cgo.a
rm -r $WORK/b010/
mkdir -p $WORK/b001/
mkdir -p /usr/local/go/pkg/linux_amd64_dynlink/
cp /root/.cache/go-build/48/480cac92b4c206e97aa16661a1fefa76cd9a7c3e9dbb6561b157192f58d9616a-d /usr/local/go/pkg/linux_amd64_dynlink/runtime.a
rm -r $WORK/b001/
mkdir -p $WORK/b009/
cat >$WORK/b009/importcfg.link << 'EOF' # internal
packagefile runtime=/usr/local/go/pkg/linux_amd64_dynlink/runtime.a
packagefile runtime=/usr/local/go/pkg/linux_amd64_dynlink/runtime.a
packagefile sync/atomic=/usr/local/go/pkg/linux_amd64_dynlink/sync/atomic.a
packagefile runtime/cgo=/usr/local/go/pkg/linux_amd64_dynlink/runtime/cgo.a
packagefile internal/bytealg=/root/.cache/go-build/eb/ebe4f17c92a8aee75ce6dde35ebe900fb9051f9ce0451e818b2cb4e091bd3a82-d
packagefile internal/cpu=/root/.cache/go-build/34/348255d3b899645de91e03b093dabb20aacdcfb760c4d0e166368ce6c0a957b0-d
packagefile runtime/internal/atomic=/root/.cache/go-build/7d/7d61822dc912c9af3aadf13e875fe00ade680203b000b9df10f75d9dbbe51ea8-d
packagefile runtime/internal/math=/root/.cache/go-build/58/580a6b969c7abd4afa1390f8534c483e4da49e4aefd6df9d6597aca1decb9dc5-d
packagefile runtime/internal/sys=/root/.cache/go-build/23/2332ce2e961520d1c3b28de68e5236255c1b44efb7c329edf19fb6ed4271b3cb-d
EOF
cd .
/usr/local/go/pkg/tool/linux_amd64/link -o $WORK/b009/libruntime,sync-atomic.so -importcfg $WORK/b009/importcfg.link -installsuffix dynlink -buildmode=shared -extld=gcc runtime=/usr/local/go/pkg/linux_amd64_dynlink/runtime.a sync/atomic=/usr/local/go/pkg/linux_amd64_dynlink/sync/atomic.a runtime/cgo=/usr/local/go/pkg/linux_amd64_dynlink/runtime/cgo.a
echo 'libruntime,sync-atomic.so' > /usr/local/go/pkg/linux_amd64_dynlink/sync/atomic.shlibname # internal
echo 'libruntime,sync-atomic.so' > /usr/local/go/pkg/linux_amd64_dynlink/runtime/cgo.shlibname # internal
echo 'libruntime,sync-atomic.so' > /usr/local/go/pkg/linux_amd64_dynlink/runtime.shlibname # internal
mv $WORK/b009/libruntime,sync-atomic.so /usr/local/go/pkg/linux_amd64_dynlink/libruntime,sync-atomic.so
rm -r $WORK/b009/

root@manoj:~/go/src# go build -linkshared httpapp.go 

root@manoj:~/go/src# ldd httpapp
	linux-vdso.so.1 =>  (0x00007ffe10de8000)
	libruntime,sync-atomic.so => /usr/local/go/pkg/linux_amd64_dynlink/libruntime,sync-atomic.so (0x00007fd34b3a5000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd34afdb000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd34adbe000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fd34b86b000)

root@manoj:~/go/src# scp /usr/local/go/pkg/linux_amd64_dynlink/libruntime,sync-atomic.so  machine2:/tmp 
libruntime,sync-atomic.so                                                                                    100% 3165KB   3.1MB/s   00:00    

root@manoj:~/go/src# scp httpapp  machine2:/tmp 
httpapp                                                                                                      100% 9250KB   4.5MB/s   00:02    

root@manoj:~/go/src# md5sum httpapp
3a033fc0122956d6e64c34bee116efc6  httpapp

root@manoj:~/go/src# go version
go version go1.15.1 linux/amd64

Loading

@ManojKumarChauhan
Copy link
Author

@ManojKumarChauhan ManojKumarChauhan commented Feb 5, 2021

another machine logs

root@ubuntu:/opt# mkdir /usr/local/go
root@ubuntu:/opt# mkdir /usr/local/go/pkg
root@ubuntu:/opt# mkdir /usr/local/go/pkg/linux_amd64_dynlink
root@ubuntu:/opt# mv /tmp/libruntime,sync-atomic.so /usr/local/go/pkg/linux_amd64_dynlink
root@ubuntu:/opt# mv /tmp/httpapp .
root@ubuntu:/opt# md5sum httpapp 
3a033fc0122956d6e64c34bee116efc6  httpapp
root@ubuntu:/opt# ldd httpapp 
	linux-vdso.so.1 =>  (0x00007ffe42feb000)
	libruntime,sync-atomic.so => /usr/local/go/pkg/linux_amd64_dynlink/libruntime,sync-atomic.so (0x00007f06c7212000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f06c6e48000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f06c6c2b000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f06c76d8000)
root@ubuntu:/opt# export LD_LIBRARY_PATH=/usr/local/go/pkg/linux_amd64_dynlink
root@ubuntu:/opt# ./httpapp 

   ____    __
  / __/___/ /  ___
 / _// __/ _ \/ _ \
/___/\__/_//_/\___/ v4.1.17
High performance, minimalist Go web framework
https://echo.labstack.com
____________________________________O/_______
                                    O\
⇨ http server started on [::]:1328
unexpected fault address 0x15b2c0
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x1 addr=0x15b2c0 pc=0x15b2c0]

goroutine 28 [running]:
runtime.throw(0x7f41ddd34a26, 0x5)
	/usr/local/go/src/runtime/panic.go:1116 +0x74 fp=0xc0000cc518 sp=0xc0000cc4e8 pc=0x7f41ddcea354
runtime.sigpanic()
	/usr/local/go/src/runtime/signal_unix.go:727 +0x428 fp=0xc0000cc548 sp=0xc0000cc518 pc=0x7f41ddd07788
crypto/sha512.blockAMD64(0xc0000cc778, 0xc0000cc7b8, 0x80, 0x80)
	/usr/local/go/src/crypto/sha512/sha512block_amd64.s:144 +0x3f15 fp=0xc0000cc550 sp=0xc0000cc548 pc=0x65a8f5
crypto/sha512.block(0xc0000cc778, 0xc0000cc7b8, 0x80, 0x80)
	/usr/local/go/src/crypto/sha512/sha512block_amd64.go:23 +0x8e fp=0xc0000cc580 sp=0xc0000cc550 pc=0x65698e
crypto/sha512.(*digest).Write(0xc0000cc778, 0xc0000cc650, 0x10, 0x80, 0x62, 0x0, 0x0)
	/usr/local/go/src/crypto/sha512/sha512.go:262 +0x1df fp=0xc0000cc5d0 sp=0xc0000cc580 pc=0x65603f
crypto/sha512.(*digest).checkSum(0xc0000cc778, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/usr/local/go/src/crypto/sha512/sha512.go:310 +0x125 fp=0xc0000cc6e0 sp=0xc0000cc5d0 pc=0x656665
crypto/sha512.(*digest).Sum(0xc0004ddea0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0)
	/usr/local/go/src/crypto/sha512/sha512.go:282 +0xa5 fp=0xc0000cc868 sp=0xc0000cc6e0 pc=0x656185
crypto/hmac.(*hmac).Sum(0xc000547b60, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0)
	/usr/local/go/src/crypto/hmac/hmac.go:57 +0x58 fp=0xc0000cc8b8 sp=0xc0000cc868 pc=0x687a98
vendor/golang.org/x/crypto/hkdf.(*hkdf).Read(0xc000512af0, 0xc000535360, 0x20, 0x20, 0xc0000a0520, 0xd, 0x10)
	/usr/local/go/src/vendor/golang.org/x/crypto/hkdf/hkdf.go:63 +0x1d3 fp=0xc0000cc918 sp=0xc0000cc8b8 pc=0x725433
crypto/tls.(*cipherSuiteTLS13).expandLabel(0xd650e0, 0xc0003e8c00, 0x30, 0x30, 0x8ab6aa, 0x3, 0x0, 0x0, 0x0, 0x20, ...)
	/usr/local/go/src/crypto/tls/key_schedule.go:46 +0x2a2 fp=0xc0000cca30 sp=0xc0000cc918 pc=0x75a3e2
crypto/tls.(*cipherSuiteTLS13).trafficKey(0xd650e0, 0xc0003e8c00, 0x30, 0x30, 0x30, 0x30, 0x30, 0xc0003e8c00, 0x30, 0x30)
	/usr/local/go/src/crypto/tls/key_schedule.go:77 +0x98 fp=0xc0000ccac0 sp=0xc0000cca30 pc=0x75aaf8
crypto/tls.(*halfConn).setTrafficSecret(0xc0000fe1f0, 0xd650e0, 0xc0003e8c00, 0x30, 0x30)
	/usr/local/go/src/crypto/tls/conn.go:215 +0x7a fp=0xc0000ccb20 sp=0xc0000ccac0 pc=0x72daba
crypto/tls.(*clientHandshakeStateTLS13).establishHandshakeKeys(0xc0000ccdf0, 0x0, 0x0)
	/usr/local/go/src/crypto/tls/handshake_client_tls13.go:360 +0x226 fp=0xc0000ccc00 sp=0xc0000ccb20 pc=0x740926
crypto/tls.(*clientHandshakeStateTLS13).handshake(0xc0000ccdf0, 0xc0000a0438, 0x4)
	/usr/local/go/src/crypto/tls/handshake_client_tls13.go:79 +0x1bb fp=0xc0000ccc50 sp=0xc0000ccc00 pc=0x73ed1b
crypto/tls.(*Conn).clientHandshake(0xc0000fe000, 0x0, 0x0)
	/usr/local/go/src/crypto/tls/handshake_client.go:209 +0x65d fp=0xc0000ccee0 sp=0xc0000ccc50 pc=0x73883d
crypto/tls.(*Conn).clientHandshake-fm(0xc000534f60, 0x19)
	/usr/local/go/src/crypto/tls/handshake_client.go:136 +0x2c fp=0xc0000ccf08 sp=0xc0000ccee0 pc=0x77426c
crypto/tls.(*Conn).Handshake(0xc0000fe000, 0x0, 0x0)
	/usr/local/go/src/crypto/tls/conn.go:1362 +0xc9 fp=0xc0000ccf78 sp=0xc0000ccf08 pc=0x736929
net/http.(*persistConn).addTLS.func2(0x0, 0xc0000fe000, 0xc000525860, 0xc000546d80)
	/usr/local/go/src/net/http/transport.go:1509 +0x45 fp=0xc0000ccfc0 sp=0xc0000ccf78 pc=0x81ed45
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:1374 +0x1 fp=0xc0000ccfc8 sp=0xc0000ccfc0 pc=0x7f41ddd2ba81
created by net/http.(*persistConn).addTLS
	/usr/local/go/src/net/http/transport.go:1505 +0x17d

goroutine 1 [IO wait, 1 minutes]:
internal/poll.runtime_pollWait(0x7f41de0ae778, 0x72, 0x0)
	/usr/local/go/src/runtime/netpoll.go:220 +0x65
internal/poll.(*pollDesc).wait(0xc00014a218, 0x72, 0x0, 0x0, 0x8ac4b7)
	/usr/local/go/src/internal/poll/fd_poll_runtime.go:87 +0x47
internal/poll.(*pollDesc).waitRead(...)
	/usr/local/go/src/internal/poll/fd_poll_runtime.go:92
internal/poll.(*FD).Accept(0xc00014a200, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/usr/local/go/src/internal/poll/fd_unix.go:394 +0x1fc
net.(*netFD).accept(0xc00014a200, 0x50, 0x50, 0xc0000e62d0)
	/usr/local/go/src/net/fd_unix.go:172 +0x45
net.(*TCPListener).accept(0xc00000e6a0, 0x29e8d60800, 0x902884, 0xc0000cfcd8)
	/usr/local/go/src/net/tcpsock_posix.go:139 +0x34
net.(*TCPListener).AcceptTCP(0xc00000e6a0, 0x9636c5522075d801, 0x0, 0x0)
	/usr/local/go/src/net/tcpsock.go:248 +0x67
github.com/labstack/echo.tcpKeepAliveListener.Accept(0xc00000e6a0, 0xc0000cfd48, 0x5b3fa8, 0x601d2d0c, 0x7f41ddcf7670)
	/root/go/src/github.com/labstack/echo/echo.go:946 +0x31
net/http.(*Server).Serve(0xc00014e000, 0xbc8f20, 0xc00003cc88, 0x0, 0x0)
	/usr/local/go/src/net/http/server.go:2937 +0x286
github.com/labstack/echo.(*Echo).serve(0xc000150000, 0xc00014e000, 0x0)
	/root/go/src/github.com/labstack/echo/echo.go:789 +0x9b
github.com/labstack/echo.(*Echo).Start(0xc000150000, 0x8abb25, 0x5, 0x8ab5e4, 0x3)
	/root/go/src/github.com/labstack/echo/echo.go:663 +0xd7
main.main()
	/root/go/src/httpapp.go:24 +0xa8

goroutine 6 [select]:
net/http.(*Transport).getConn(0xd6b100, 0xc000361380, 0x0, 0x8bbe0e, 0x5, 0xc000534f60, 0x19, 0x0, 0x0, 0x0, ...)
	/usr/local/go/src/net/http/transport.go:1347 +0x5a9
net/http.(*Transport).roundTrip(0xd6b100, 0xc000172700, 0x30, 0xc000540ff0, 0x7f41b4a59008)
	/usr/local/go/src/net/http/transport.go:569 +0x78e
net/http.(*Transport).RoundTrip(0xd6b100, 0xc000172700, 0xd6b100, 0x0, 0x0)
	/usr/local/go/src/net/http/roundtrip.go:17 +0x37
net/http.send(0xc000172700, 0xbc2c20, 0xd6b100, 0x0, 0x0, 0x0, 0xc00003c028, 0x203000, 0x1, 0x0)
	/usr/local/go/src/net/http/client.go:252 +0x45a
net/http.(*Client).send(0xc000540f90, 0xc000172700, 0x0, 0x0, 0x0, 0xc00003c028, 0x0, 0x1, 0xc000172700)
	/usr/local/go/src/net/http/client.go:176 +0xff
net/http.(*Client).do(0xc000540f90, 0xc000172700, 0x0, 0x0, 0x0)
	/usr/local/go/src/net/http/client.go:718 +0x46f
net/http.(*Client).Do(...)
	/usr/local/go/src/net/http/client.go:586
main.mainAdmin(0xbcdfe0, 0xc00011cfa0, 0x0, 0x0)
	/root/go/src/httpapp.go:13 +0x158
github.com/labstack/echo.(*Echo).add.func1(0xbcdfe0, 0xc00011cfa0, 0x0, 0x0)
	/root/go/src/github.com/labstack/echo/echo.go:536 +0x64
github.com/labstack/echo.(*Echo).ServeHTTP(0xc000150000, 0xbc9360, 0xc00040fea0, 0xc000172600)
	/root/go/src/github.com/labstack/echo/echo.go:646 +0x187
net/http.serverHandler.ServeHTTP(0xc00014e000, 0xbc9360, 0xc00040fea0, 0xc000172600)
	/usr/local/go/src/net/http/server.go:2843 +0xa5
net/http.(*conn).serve(0xc00011cf00, 0xbc9f20, 0xc000036340)
	/usr/local/go/src/net/http/server.go:1925 +0x8b1
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:2969 +0x394

goroutine 22 [chan receive]:
net/http.(*persistConn).addTLS(0xc000542360, 0xc000534f60, 0x15, 0x0, 0xc000534f76, 0x3)
	/usr/local/go/src/net/http/transport.go:1515 +0x1a6
net/http.(*Transport).dialConn(0xd6b100, 0xbc9f60, 0xc0000a00b8, 0x0, 0x8bbe0e, 0x5, 0xc000534f60, 0x19, 0x0, 0xc000542360, ...)
	/usr/local/go/src/net/http/transport.go:1585 +0x1d67
net/http.(*Transport).dialConnFor(0xd6b100, 0xc000188210)
	/usr/local/go/src/net/http/transport.go:1421 +0xc8
created by net/http.(*Transport).queueForDial
	/usr/local/go/src/net/http/transport.go:1390 +0x42f

goroutine 21 [IO wait]:
internal/poll.runtime_pollWait(0x7f41de0ae698, 0x72, 0xbc3b80)
	/usr/local/go/src/runtime/netpoll.go:220 +0x65
internal/poll.(*pollDesc).wait(0xc00014a298, 0x72, 0xc000081500, 0x1, 0x1)
	/usr/local/go/src/internal/poll/fd_poll_runtime.go:87 +0x47
internal/poll.(*pollDesc).waitRead(...)
	/usr/local/go/src/internal/poll/fd_poll_runtime.go:92
internal/poll.(*FD).Read(0xc00014a280, 0xc000081571, 0x1, 0x1, 0x0, 0x0, 0x0)
	/usr/local/go/src/internal/poll/fd_unix.go:159 +0x1b1
net.(*netFD).Read(0xc00014a280, 0xc000081571, 0x1, 0x1, 0x0, 0x0, 0x0)
	/usr/local/go/src/net/fd_posix.go:55 +0x51
net.(*conn).Read(0xc00003cc98, 0xc000081571, 0x1, 0x1, 0x0, 0x0, 0x0)
	/usr/local/go/src/net/net.go:182 +0x90
net/http.(*connReader).backgroundRead(0xc000081560)
	/usr/local/go/src/net/http/server.go:690 +0x5a
created by net/http.(*connReader).startBackgroundRead
	/usr/local/go/src/net/http/server.go:686 +0xd5

root@ubuntu:/opt# 

Loading

@ManojKumarChauhan
Copy link
Author

@ManojKumarChauhan ManojKumarChauhan commented Feb 5, 2021

can you please include the exact steps to reproduce this? because this works:

FROM golang:1.15-buster AS build
WORKDIR /go/src/example.com/app
RUN go install -x -buildmode=shared runtime sync/atomic
COPY httpapp.go .
RUN go get . && go build -linkshared


FROM ubuntu:16.04
WORKDIR /app
COPY --from=build /usr/local/go/pkg/linux_amd64_dynlink /usr/local/go/pkg/linux_amd64_dynlink
COPY --from=build /go/src/example.com/app/app .
ENTRYPOINT /app/app

After launching http app, i access it through browser ipofmachine2:1328/main. Hitting the browser after few seconds (max 1 minute) delay the app got crashed.

Loading

@seankhliao seankhliao changed the title runtime: crash when built with linkshared runtime: segmentation violation with linkshared Feb 5, 2021
@ManojKumarChauhan
Copy link
Author

@ManojKumarChauhan ManojKumarChauhan commented Feb 9, 2021

Hi @seankhliao ,
Please change the label as I cannot do this.

For go runtime, I also faced following issues:

Two machines have same/different go versions. From machine 1, I create a shared library (go build -linkshared -buildmode=shared) with/without runtime. From another machine I create httpapp(go build -linkshared httpapp.go) with/without runtime. If I want to use the library created from machine 1 in httpapp at machine 2 then dlopen does not work. So I used LD_PRELOAD to load the library but this does not allow the httpapp to get launch. httpapp is crashed sometimes in "abi mismatch" or sometimes in fmt/print.go:274 or sometimes somewhere else.
So could you please suggest how to use a go library (created on machine 1) on another machine without moving the code of go library on another machine.

Loading

@ManojKumarChauhan
Copy link
Author

@ManojKumarChauhan ManojKumarChauhan commented Feb 25, 2021

any update on this?

Loading

@networkimprov
Copy link

@networkimprov networkimprov commented Feb 28, 2021

Loading

@ManojKumarChauhan
Copy link
Author

@ManojKumarChauhan ManojKumarChauhan commented May 3, 2021

Should I close this issue?

Loading

@networkimprov
Copy link

@networkimprov networkimprov commented May 11, 2021

Are you still seeing this with the latest 1.15 and 1.16 releases? If so, we need to Cc folks on the compiler/linker team...

Loading

@ManojKumarChauhan
Copy link
Author

@ManojKumarChauhan ManojKumarChauhan commented May 13, 2021

As I remember I checked it on latest release of 1.15 and the issue exists. I will check it on 1.16 & confirm.

Loading

@ManojKumarChauhan
Copy link
Author

@ManojKumarChauhan ManojKumarChauhan commented Jun 14, 2021

Nor reproducing in go version 1.16

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants