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

Race condition #23

Open
equals215 opened this issue Apr 3, 2024 · 1 comment
Open

Race condition #23

equals215 opened this issue Apr 3, 2024 · 1 comment

Comments

@equals215
Copy link

A race condition happens when opening a client

Here's the error

==================
WARNING: DATA RACE
Write at 0x00c000136140 by goroutine 7:
  github.com/james-barrow/golang-ipc.startClient()
      /Users/thomas/go/pkg/mod/github.com/james-barrow/[email protected]/client_all.go:63 +0x38
  github.com/james-barrow/golang-ipc.StartClient.func1()
      /Users/thomas/go/pkg/mod/github.com/james-barrow/[email protected]/client_all.go:56 +0x34

Previous read at 0x00c000136140 by main goroutine:
  github.com/james-barrow/golang-ipc.(*Client).Write()
      /Users/thomas/go/pkg/mod/github.com/james-barrow/[email protected]/client_all.go:198 +0x4c
  main.startIPCClient()
      /Users/thomas/go/src/github.com/equals215/deepsentinel/agent/test-tbd/main.go:18 +0x9c
  main.main()
      /Users/thomas/go/src/github.com/equals215/deepsentinel/agent/test-tbd/main.go:10 +0x20

Goroutine 7 (running) created at:
  github.com/james-barrow/golang-ipc.StartClient()
      /Users/thomas/go/pkg/mod/github.com/james-barrow/[email protected]/client_all.go:56 +0x388
  main.startIPCClient()
      /Users/thomas/go/src/github.com/equals215/deepsentinel/agent/test-tbd/main.go:14 +0x58
  main.main()
      /Users/thomas/go/src/github.com/equals215/deepsentinel/agent/test-tbd/main.go:10 +0x20
==================
Found 1 data race(s)
exit status 66

Here's the code that trigger this race condition :

package main

import (
	"fmt"

	ipc "github.com/james-barrow/golang-ipc"
)

func main() {
	startIPCClient()
}

func startIPCClient() (*ipc.Client, error) {
	c, err := ipc.StartClient("testIPC", &ipc.ClientConfig{Timeout: 500})
	if err != nil {
		return nil, err
	}
	c.Write(1, []byte("ping"))
	resp, err := c.Read()
	if err != nil {
		return nil, err
	}

	if string(resp.Data) != "pong" {
		return nil, fmt.Errorf("unexpected response: %s", resp.Data)
	}
	return c, nil
}
@equals215
Copy link
Author

Abandoned the use of this package, letting this issue open for the sake of it. Won't provide help.

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

1 participant