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 detected when send command to the running proxy #1

Closed
euiko opened this issue Feb 6, 2021 · 4 comments
Closed

Race detected when send command to the running proxy #1

euiko opened this issue Feb 6, 2021 · 4 comments

Comments

@euiko
Copy link
Contributor

euiko commented Feb 6, 2021

To reproduce this just call the proxy run, and perform RawCommands and test it with -race option, it should give detected race conditions in many cases.
Or just build the provided example with -race option.

Look like there is a race condition on reading std out/err while waiting spawned program to be exited through calls cmd.Wait() such as mentioned in issue golang/go#19685
Consider fix like mentioned in the comments golang/go#19685 (comment)
But the observed behavior look like doesn't directly impact the functionality of the library and still need to be checked more in depth

@galihrivanto
Copy link
Owner

while I will try to add unit test for racescenario, can you test whether latest release have similar issue v0.1.1?
https://github.com/galihrivanto/go-inkscape/releases/tag/v0.1.1

@euiko
Copy link
Contributor Author

euiko commented Feb 7, 2021

the issue is also reproduced on v0.1.1 tag
here is the git log that I've checked out :

commit c34a6a45609ed40f2e5be9b16de462d3287d3c1c (HEAD, tag: v0.1.1, origin/master, origin/HEAD, master)
Author: galih rivanto <[email protected]>
Date:   Fri Feb 5 16:04:21 2021 +0700

    fix race during proxy running

the issue still existed as with below race information :

> ./svg2pdf -input test.svg -output out.pdf
==================
WARNING: DATA RACE
Write at 0x00c000300000 by goroutine 10:
  internal/race.WriteRange()
      /usr/lib/go/src/internal/race/race.go:49 +0x9a
  syscall.Read()
      /usr/lib/go/src/syscall/syscall_unix.go:190 +0x7e
  internal/poll.(*FD).Read.func1()
      /usr/lib/go/src/internal/poll/fd_unix.go:155 +0xa4
  internal/poll.ignoringEINTR()
      /usr/lib/go/src/internal/poll/fd_unix.go:567 +0x38
  internal/poll.(*FD).Read()
      /usr/lib/go/src/internal/poll/fd_unix.go:155 +0x1cd
  os.(*File).read()
      /usr/lib/go/src/os/file_posix.go:31 +0xb1
  os.(*File).Read()
      /usr/lib/go/src/os/file.go:116 +0x6b
  io.copyBuffer()
      /usr/lib/go/src/io/io.go:409 +0x14b
  io.Copy()
      /usr/lib/go/src/io/io.go:368 +0x7a
  os/exec.(*Cmd).writerDescriptor.func1()
      /usr/lib/go/src/os/exec/exec.go:311 +0x4a
  os/exec.(*Cmd).Start.func1()
      /usr/lib/go/src/os/exec/exec.go:441 +0x38

Previous read at 0x00c000300000 by main goroutine:
  bytes.Index()
      /usr/lib/go/src/bytes/bytes.go:1116 +0x18d
  bytes.Contains()
      /usr/lib/go/src/bytes/bytes.go:76 +0x469
  github.com/galihrivanto/go-inkscape.(*Proxy).sendCommand()
      /home/euiko/Sources/galihrivanto/go-inkscape/proxy.go:213 +0x3f0
  github.com/galihrivanto/go-inkscape.(*Proxy).RawCommands()
      /home/euiko/Sources/galihrivanto/go-inkscape/proxy.go:233 +0x1de
  github.com/galihrivanto/go-inkscape.(*Proxy).Svg2Pdf()
      /home/euiko/Sources/galihrivanto/go-inkscape/proxy.go:238 +0x199
  main.main()
      /home/euiko/Sources/galihrivanto/go-inkscape/cmd/svg2pdf/main.go:38 +0x36f

Goroutine 10 (running) created at:
  os/exec.(*Cmd).Start()
      /usr/lib/go/src/os/exec/exec.go:440 +0xaaa
  github.com/galihrivanto/go-inkscape.(*Proxy).runBackground()
      /home/euiko/Sources/galihrivanto/go-inkscape/proxy.go:104 +0x404
  github.com/galihrivanto/go-inkscape.(*Proxy).Run.func1.1()
      /home/euiko/Sources/galihrivanto/go-inkscape/proxy.go:128 +0x86
  github.com/galihrivanto/runner.doOperation()
      /home/euiko/Sources/go/pkg/mod/github.com/galihrivanto/[email protected]/runner.go:98 +0x89
  github.com/galihrivanto/runner.RunWithRetry.func1()
      /home/euiko/Sources/go/pkg/mod/github.com/galihrivanto/[email protected]/runner.go:111 +0x9a
==================
==================
WARNING: DATA RACE
Write at 0x00c000300001 by goroutine 10:
  internal/race.WriteRange()
      /usr/lib/go/src/internal/race/race.go:49 +0x9a
  syscall.Read()
      /usr/lib/go/src/syscall/syscall_unix.go:190 +0x7e
  internal/poll.(*FD).Read.func1()
      /usr/lib/go/src/internal/poll/fd_unix.go:155 +0xa4
  internal/poll.ignoringEINTR()
      /usr/lib/go/src/internal/poll/fd_unix.go:567 +0x38
  internal/poll.(*FD).Read()
      /usr/lib/go/src/internal/poll/fd_unix.go:155 +0x1cd
  os.(*File).read()
      /usr/lib/go/src/os/file_posix.go:31 +0xb1
  os.(*File).Read()
      /usr/lib/go/src/os/file.go:116 +0x6b
  io.copyBuffer()
      /usr/lib/go/src/io/io.go:409 +0x14b
  io.Copy()
      /usr/lib/go/src/io/io.go:368 +0x7a
  os/exec.(*Cmd).writerDescriptor.func1()
      /usr/lib/go/src/os/exec/exec.go:311 +0x4a
  os/exec.(*Cmd).Start.func1()
      /usr/lib/go/src/os/exec/exec.go:441 +0x38

Previous read at 0x00c000300001 by main goroutine:
  bytes.Index()
      /usr/lib/go/src/bytes/bytes.go:1125 +0x1e6
  bytes.Contains()
      /usr/lib/go/src/bytes/bytes.go:76 +0x469
  github.com/galihrivanto/go-inkscape.(*Proxy).sendCommand()
      /home/euiko/Sources/galihrivanto/go-inkscape/proxy.go:213 +0x3f0
  github.com/galihrivanto/go-inkscape.(*Proxy).RawCommands()
      /home/euiko/Sources/galihrivanto/go-inkscape/proxy.go:233 +0x1de
  github.com/galihrivanto/go-inkscape.(*Proxy).Svg2Pdf()
      /home/euiko/Sources/galihrivanto/go-inkscape/proxy.go:238 +0x199
  main.main()
      /home/euiko/Sources/galihrivanto/go-inkscape/cmd/svg2pdf/main.go:38 +0x36f

Goroutine 10 (running) created at:
  os/exec.(*Cmd).Start()
      /usr/lib/go/src/os/exec/exec.go:440 +0xaaa
  github.com/galihrivanto/go-inkscape.(*Proxy).runBackground()
      /home/euiko/Sources/galihrivanto/go-inkscape/proxy.go:104 +0x404
  github.com/galihrivanto/go-inkscape.(*Proxy).Run.func1.1()
      /home/euiko/Sources/galihrivanto/go-inkscape/proxy.go:128 +0x86
  github.com/galihrivanto/runner.doOperation()
      /home/euiko/Sources/go/pkg/mod/github.com/galihrivanto/[email protected]/runner.go:98 +0x89
  github.com/galihrivanto/runner.RunWithRetry.func1()
      /home/euiko/Sources/go/pkg/mod/github.com/galihrivanto/[email protected]/runner.go:111 +0x9a
==================
done!!
Found 2 data race(s)
[1]    84900 exit 66    ./svg2pdf -input test.svg -output out.pdf

@euiko
Copy link
Contributor Author

euiko commented Feb 11, 2021

Please review the PR #2

@galihrivanto
Copy link
Owner

should be closed by #2

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