We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
go version
go version go1.10.3 darwin/amd64
Yes
go env
GOARCH="amd64" GOOS="darwin"
main.go:
package main import ( "log" "plugin" "./client" ) func main() { p, err := plugin.Open("plugin.so") if err != nil { log.Fatal(err) } s, err := p.Lookup("NewHTTPClient") if err != nil { log.Fatal(err) } f, ok := s.(func() client.Client) if !ok { log.Fatal("cannot cast Symbol to NewHTTPClient") } c := f() res, err := c.Get("https://google.com") if err != nil { log.Fatal(err) } log.Println(res) }
plugin.go:
package main import ( "net/http" "./client" ) func NewHTTPClient() client.Client { return &client.HTTPClient{ Client: http.Client{}, } }
./client/client.go:
package client import ( "bytes" "net/http" ) type Client interface { Get(url string) (*http.Response, error) } type HTTPClient struct { Client http.Client } func (h *HTTPClient) Get(url string) (*http.Response, error) { req, err := http.NewRequest("GET", url, bytes.NewBuffer([]byte{})) if err != nil { return nil, err } return h.Client.Do(req) }
Run:
go build -buildmode=plugin -o plugin.so plugin.go go run main.go
Try without TLS to get another invalid pointer trace output.
Response from google.com is logged to the console.
runtime: bad pointer in frame crypto/tls.(*clientHandshakeState).handshake at 0xc420047d68: 0x4 fatal error: invalid pointer found on stack runtime stack: runtime.throw(0x542bc72, 0x1e) /usr/local/opt/go/libexec/src/runtime/panic.go:616 +0x81 fp=0x70000843a708 sp=0x70000843a6e8 pc=0x516a1e1 runtime.adjustpointers(0xc420047d60, 0x70000843a800, 0x70000843abc0, 0x5537c70, 0x55815a0) /usr/local/opt/go/libexec/src/runtime/stack.go:592 +0x23e fp=0x70000843a778 sp=0x70000843a708 pc=0x517fd0e runtime.adjustframe(0x70000843aad0, 0x70000843abc0, 0x55815a0) /usr/local/opt/go/libexec/src/runtime/stack.go:663 +0x325 fp=0x70000843a830 sp=0x70000843a778 pc=0x5180055 runtime.gentraceback(0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xc420001c80, 0x0, 0x0, 0x7fffffff, 0x5437ce8, 0x70000843abc0, 0x0, ...) /usr/local/opt/go/libexec/src/runtime/traceback.go:310 +0x12d3 fp=0x70000843ab38 sp=0x70000843a830 pc=0x5188ef3 runtime.copystack(0xc420001c80, 0x1000, 0x700000000e01) /usr/local/opt/go/libexec/src/runtime/stack.go:891 +0x26e fp=0x70000843acf0 sp=0x70000843ab38 pc=0x5180b3e runtime.newstack() /usr/local/opt/go/libexec/src/runtime/stack.go:1063 +0x310 fp=0x70000843ae80 sp=0x70000843acf0 pc=0x5180f50 runtime.morestack() /usr/local/opt/go/libexec/src/runtime/asm_amd64.s:480 +0x89 fp=0x70000843ae88 sp=0x70000843ae80 pc=0x518ee89 goroutine 11 [copystack]: runtime.(*mcache).nextFree(0x4576000, 0xc42006211b, 0x0, 0x0, 0x0) /usr/local/opt/go/libexec/src/runtime/malloc.go:545 +0x254 fp=0xc420047b10 sp=0xc420047b08 pc=0x5151114 runtime.mallocgc(0xc0, 0x4275580, 0x1, 0x0) /usr/local/opt/go/libexec/src/runtime/malloc.go:710 +0x7e5 fp=0xc420047bb0 sp=0xc420047b10 pc=0x5151905 runtime.makeslice(0x4275580, 0xb2, 0xb2, 0xc42001a2a0, 0x3, 0xc420022070) /usr/local/opt/go/libexec/src/runtime/slice.go:61 +0x77 fp=0xc420047be0 sp=0xc420047bb0 pc=0x517e747 crypto/tls.(*clientHelloMsg).marshal(0xc4200c0280, 0x20, 0x20, 0x20) /usr/local/opt/go/libexec/src/crypto/tls/handshake_messages.go:117 +0x1a1 fp=0xc420047cd8 sp=0xc420047be0 pc=0x52f5761 crypto/tls.(*clientHandshakeState).handshake(0xc420036e70, 0xc4200c0280, 0x0) /usr/local/opt/go/libexec/src/crypto/tls/handshake_client.go:187 +0x52 fp=0xc420047df0 sp=0xc420047cd8 pc=0x52f04c2 crypto/tls.(*Conn).clientHandshake(0xc42008ca80, 0x5437fb8, 0xc42008cba0) /usr/local/opt/go/libexec/src/crypto/tls/handshake_client.go:168 +0x395 fp=0xc420047f28 sp=0xc420047df0 pc=0x52f0205 crypto/tls.(*Conn).Handshake(0xc42008ca80, 0x0, 0x0) /usr/local/opt/go/libexec/src/crypto/tls/conn.go:1329 +0x189 fp=0xc420047f78 sp=0xc420047f28 pc=0x52eee49 net/http.(*persistConn).addTLS.func2(0x0, 0xc42008ca80, 0xc4200924b0, 0xc420072780) /usr/local/opt/go/libexec/src/net/http/transport.go:1068 +0x42 fp=0xc420047fc0 sp=0xc420047f78 pc=0x53779a2 runtime.goexit() /usr/local/opt/go/libexec/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc420047fc8 sp=0xc420047fc0 pc=0x5191831 created by net/http.(*persistConn).addTLS /usr/local/opt/go/libexec/src/net/http/transport.go:1064 +0x1a7 goroutine 1 [select]: runtime.gopark(0x5437f30, 0x0, 0x5425430, 0x6, 0x18, 0x1) /usr/local/opt/go/libexec/src/runtime/proc.go:291 +0x126 fp=0xc420057368 sp=0xc420057348 pc=0x516bb86 runtime.selectgo(0xc420057790, 0xc420072120) /usr/local/opt/go/libexec/src/runtime/select.go:392 +0xe96 fp=0xc420057540 sp=0xc420057368 pc=0x5179b26 net/http.(*Transport).getConn(0x4460ce0, 0xc420086f00, 0x0, 0x42de28c, 0x5, 0xc420016490, 0xe, 0x0, 0x0, 0x0) /usr/local/opt/go/libexec/src/net/http/transport.go:962 +0x55e fp=0xc4200578c0 sp=0xc420057540 pc=0x536ceae net/http.(*Transport).RoundTrip(0x4460ce0, 0xc42013c000, 0x4460ce0, 0x0, 0x0) /usr/local/opt/go/libexec/src/net/http/transport.go:409 +0x62e fp=0xc420057b08 sp=0xc4200578c0 pc=0x536967e net/http.send(0xc42013c000, 0x5459b60, 0x4460ce0, 0x0, 0x0, 0x0, 0xc4201269d8, 0x20, 0xc420057ca0, 0x1) /usr/local/opt/go/libexec/src/net/http/client.go:252 +0x185 fp=0xc420057c30 sp=0xc420057b08 pc=0x533ece5 net/http.(*Client).send(0xc420086d80, 0xc42013c000, 0x0, 0x0, 0x0, 0xc4201269d8, 0x0, 0x1, 0x5151cb8) /usr/local/opt/go/libexec/src/net/http/client.go:176 +0xfa fp=0xc420057cb0 sp=0xc420057c30 pc=0x533e9ba net/http.(*Client).Do(0xc420086d80, 0xc42013c000, 0x42de28c, 0x12, 0x430fd80) /usr/local/opt/go/libexec/src/net/http/client.go:615 +0x298 fp=0xc420057e38 sp=0xc420057cb0 pc=0x5340048 _test_nil/client.(*HTTPClient).Get(0xc420086d80, 0x42de28c, 0x12, 0xd, 0xc42009f3a8, 0x408090004298880) test_nil/client/client.go:22 +0xf4 fp=0xc420057e98 sp=0xc420057e38 pc=0x5383864 main.main() test_nil/main.go:28 +0x19a fp=0xc420057f88 sp=0xc420057e98 pc=0x423dbea runtime.main() /usr/local/opt/go/libexec/src/runtime/proc.go:198 +0x212 fp=0xc420057fe0 sp=0xc420057f88 pc=0x402d2b2 runtime.goexit() /usr/local/opt/go/libexec/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc420057fe8 sp=0xc420057fe0 pc=0x40565a1 goroutine 2 [force gc (idle)]: runtime.gopark(0x42ee698, 0x44651c0, 0x42dd4a1, 0xf, 0x42ee514, 0x1) /usr/local/opt/go/libexec/src/runtime/proc.go:291 +0x11a fp=0xc420034768 sp=0xc420034748 pc=0x402d70a runtime.goparkunlock(0x44651c0, 0x42dd4a1, 0xf, 0x14, 0x1) /usr/local/opt/go/libexec/src/runtime/proc.go:297 +0x5e fp=0xc4200347a8 sp=0xc420034768 pc=0x402d7be runtime.forcegchelper() /usr/local/opt/go/libexec/src/runtime/proc.go:248 +0xcc fp=0xc4200347e0 sp=0xc4200347a8 pc=0x402d54c runtime.goexit() /usr/local/opt/go/libexec/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc4200347e8 sp=0xc4200347e0 pc=0x40565a1 created by runtime.init.4 /usr/local/opt/go/libexec/src/runtime/proc.go:237 +0x35 goroutine 3 [GC sweep wait]: runtime.gopark(0x42ee698, 0x44652a0, 0x42dcc3d, 0xd, 0x401f714, 0x1) /usr/local/opt/go/libexec/src/runtime/proc.go:291 +0x11a fp=0xc420034f60 sp=0xc420034f40 pc=0x402d70a runtime.goparkunlock(0x44652a0, 0x42dcc3d, 0xd, 0x14, 0x1) /usr/local/opt/go/libexec/src/runtime/proc.go:297 +0x5e fp=0xc420034fa0 sp=0xc420034f60 pc=0x402d7be runtime.bgsweep(0xc420064000) /usr/local/opt/go/libexec/src/runtime/mgcsweep.go:52 +0xa3 fp=0xc420034fd8 sp=0xc420034fa0 pc=0x401f823 runtime.goexit() /usr/local/opt/go/libexec/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc420034fe0 sp=0xc420034fd8 pc=0x40565a1 created by runtime.gcenable /usr/local/opt/go/libexec/src/runtime/mgc.go:216 +0x58 goroutine 4 [finalizer wait]: runtime.gopark(0x42ee698, 0x4482df0, 0x42dd138, 0xe, 0x14, 0x1) /usr/local/opt/go/libexec/src/runtime/proc.go:291 +0x11a fp=0xc420035718 sp=0xc4200356f8 pc=0x402d70a runtime.goparkunlock(0x4482df0, 0x42dd138, 0xe, 0x14, 0x1) /usr/local/opt/go/libexec/src/runtime/proc.go:297 +0x5e fp=0xc420035758 sp=0xc420035718 pc=0x402d7be runtime.runfinq() /usr/local/opt/go/libexec/src/runtime/mfinal.go:175 +0xad fp=0xc4200357e0 sp=0xc420035758 pc=0x40168cd runtime.goexit() /usr/local/opt/go/libexec/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc4200357e8 sp=0xc4200357e0 pc=0x40565a1 created by runtime.createfing /usr/local/opt/go/libexec/src/runtime/mfinal.go:156 +0x62 goroutine 5 [chan receive]: runtime.gopark(0x5437ef8, 0xc4200727d8, 0x54266bb, 0xc, 0x42a0117, 0x3) /usr/local/opt/go/libexec/src/runtime/proc.go:291 +0x126 fp=0xc420059808 sp=0xc4200597e8 pc=0x516bb86 runtime.goparkunlock(0xc4200727d8, 0x54266bb, 0xc, 0xc420066017, 0x3) /usr/local/opt/go/libexec/src/runtime/proc.go:297 +0x5e fp=0xc420059848 sp=0xc420059808 pc=0x516bc3e runtime.chanrecv(0xc420072780, 0xc420059a30, 0x1, 0x536d7f7) /usr/local/opt/go/libexec/src/runtime/chan.go:518 +0x304 fp=0xc4200598e0 sp=0xc420059848 pc=0x5146114 runtime.chanrecv1(0xc420072780, 0xc420059a30) /usr/local/opt/go/libexec/src/runtime/chan.go:400 +0x2b fp=0xc420059910 sp=0xc4200598e0 pc=0x5145dfb net/http.(*persistConn).addTLS(0xc42009f560, 0xc420016490, 0xa, 0x0, 0xc42001649b, 0x3) /usr/local/opt/go/libexec/src/net/http/transport.go:1074 +0x1d0 fp=0xc420059af8 sp=0xc420059910 pc=0x536d820 net/http.(*Transport).dialConn(0x4460ce0, 0x43140a0, 0xc420016090, 0x0, 0x42de28c, 0x5, 0xc420016490, 0xe, 0x0, 0x0, ...) /usr/local/opt/go/libexec/src/net/http/transport.go:1153 +0x1515 fp=0xc420059f38 sp=0xc420059af8 pc=0x536f145 net/http.(*Transport).getConn.func4(0x4460ce0, 0x43140a0, 0xc420016090, 0xc420086f30, 0xc420020240) /usr/local/opt/go/libexec/src/net/http/transport.go:957 +0x76 fp=0xc420059fb8 sp=0xc420059f38 pc=0x53778a6 runtime.goexit() /usr/local/opt/go/libexec/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc420059fc0 sp=0xc420059fb8 pc=0x5191831 created by net/http.(*Transport).getConn /usr/local/opt/go/libexec/src/net/http/transport.go:956 +0x36d goroutine 6 [syscall]: runtime.notetsleepg(0x44696a0, 0x2540bb58a, 0x1) /usr/local/opt/go/libexec/src/runtime/lock_sema.go:280 +0x4b fp=0xc420035f60 sp=0xc420035f20 pc=0x4010b4b runtime.timerproc(0x4469680) /usr/local/opt/go/libexec/src/runtime/time.go:261 +0x2e7 fp=0xc420035fd8 sp=0xc420035f60 pc=0x4048bc7 runtime.goexit() /usr/local/opt/go/libexec/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc420035fe0 sp=0xc420035fd8 pc=0x40565a1 created by runtime.(*timersBucket).addtimerLocked /usr/local/opt/go/libexec/src/runtime/time.go:160 +0x107 exit status 2
I'm not sure, but maybe I'm missing something and that causes that invalid pointer.
The text was updated successfully, but these errors were encountered:
Seems fixed at tip. Probably #24653 . If you can try patching CL https://go-review.googlesource.com/c/go/+/104715 into your Go distribution, run make.bash, try again, and report back, that would be helpful.
Sorry, something went wrong.
@randall77 thanks, I'll try it and report back.
I was able to reproduce the expected behavior at tip (at least on GOHOSTARCH="amd64" GOHOSTOS="darwin").
@CSharpRU I'm not sure what's wrong with your make attempt, but you can download go1.11 beta here: https://golang.org/dl/#go1.11beta1 which exhibits the expected behavior.
Thanks, then I'm closing it and waiting for the release.
No branches or pull requests
What version of Go are you using (
go version
)?go version go1.10.3 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOOS="darwin"
What did you do?
main.go:
plugin.go:
./client/client.go:
Run:
Try without TLS to get another invalid pointer trace output.
What did you expect to see?
Response from google.com is logged to the console.
What did you see instead?
I'm not sure, but maybe I'm missing something and that causes that invalid pointer.
The text was updated successfully, but these errors were encountered: