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

Client connection cause server panic on ARM #38

Open
IS-Martin opened this issue Dec 8, 2022 · 2 comments
Open

Client connection cause server panic on ARM #38

IS-Martin opened this issue Dec 8, 2022 · 2 comments

Comments

@IS-Martin
Copy link

IS-Martin commented Dec 8, 2022

Hi,

As title, it seems to relate to golang/go#23345.
Is there any way to avoid this problem?

Here is my test steps.

  1. Sample code
package main

import (
	"log"
	"time"
	"github.com/valyala/gorpc"
)

func main() {
	go func() {
		s := &gorpc.Server{
			// Accept clients on this TCP address.
			Addr: "0.0.0.0:12345",
	
			// Echo handler - just return back the message we received from the client
			Handler: func(clientAddr string, request interface{}) interface{} {
				log.Printf("Obtained request %+v from the client %s\n", request, clientAddr)
				return request
			},
		}
		if err := s.Serve(); err != nil {
			log.Fatalf("Cannot start rpc server: %s", err)
		}	
	}()
		
	c := &gorpc.Client{
		// TCP address of the server.
		Addr: "127.0.0.1:12345",
	}
	c.Start()
	time.Sleep(3 * time.Second)

	// All client methods issuing RPCs are thread-safe and goroutine-safe,
	// i.e. it is safe to call them from multiple concurrently running goroutines.
	resp, err := c.Call("foobar")
	if err != nil {
		log.Fatalf("Error when sending request to server: %s", err)
	}
	if resp.(string) != "foobar" {
		log.Fatalf("Unexpected response from the server: %+v", resp)
	}
	log.Printf("resp: %v", resp)
}
  1. Use go1.9, and build with GOARCH=arm GOARM=7 GOOS=linux go build -o testgorpc ./main.go
  2. Run testgorpc and get panic as the client connects to the server.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x4 pc=0x114fc]

goroutine 8 [running]:
sync/atomic.addUint64(0x10598084, 0x1, 0x0, 0x10523708, 0x11afb4)
	/usr/local/go/src/sync/atomic/64bit_arm.go:31 +0x4c
github.com/valyala/gorpc.(*ConnStats).incAcceptCalls(0x10598034)
	/go/src/github.com/valyala/gorpc/conn_stats_generic.go:87 +0x34
github.com/valyala/gorpc.serverHandler(0x10598000, 0x10518300)
	/go/src/github.com/valyala/gorpc/server.go:207 +0x1b0
created by github.com/valyala/gorpc.(*Server).Start
	/go/src/github.com/valyala/gorpc/server.go:158 +0x2e8
@aea7
Copy link

aea7 commented Feb 14, 2023

you should fork and fix this issue imho, the repo hasn't been active for 7 years.

@IS-Martin
Copy link
Author

I see. Thank you for the info.

Should I close this issue, then?

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