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

Fix data race of Scp #56

Merged
merged 2 commits into from
Apr 28, 2020
Merged

Fix data race of Scp #56

merged 2 commits into from
Apr 28, 2020

Conversation

july2993
Copy link
Contributor

@july2993 july2993 commented Apr 27, 2020

fix DATA RACE

    Fix data race

    ==================
    WARNING: DATA RACE
    Write at 0x00c000397240 by goroutine 83:
      golang.org/x/crypto/ssh.(*Session).start()
          /go/pkg/mod/golang.org/x/[email protected]/ssh/session.go:373 +0x42
      golang.org/x/crypto/ssh.(*Session).Start()
          /go/pkg/mod/golang.org/x/[email protected]/ssh/session.go:293 +0x28f
      golang.org/x/crypto/ssh.(*Session).Run()
          /go/pkg/mod/golang.org/x/[email protected]/ssh/session.go:310 +0x50
      github.com/appleboy/easyssh-proxy.(*MakeConfig).Scp()
          /go/pkg/mod/github.com/appleboy/[email protected]/easyssh.go:356 +0x2e0
    ....

    Previous read at 0x00c000397240 by goroutine 72:
      golang.org/x/crypto/ssh.(*Session).StdinPipe()
          /go/pkg/mod/golang.org/x/[email protected]/ssh/session.go:545 +0x3d7
      github.com/appleboy/easyssh-proxy.(*MakeConfig).Scp.func1()
          /go/pkg/mod/github.com/appleboy/[email protected]/easyssh.go:339 +0x7c

We must call session.StdinPipe before session.Run or session.StdinPipe will return error if it's started.

The origin implementation will just silently quit, Scp() returning nil, but the file IS NOT copy to remote actually.

This PR also check all write to the write and returning the error if we failed to do this.

==================
WARNING: DATA RACE
Write at 0x00c000397240 by goroutine 83:
  golang.org/x/crypto/ssh.(*Session).start()
      /go/pkg/mod/golang.org/x/[email protected]/ssh/session.go:373 +0x42
  golang.org/x/crypto/ssh.(*Session).Start()
      /go/pkg/mod/golang.org/x/[email protected]/ssh/session.go:293 +0x28f
  golang.org/x/crypto/ssh.(*Session).Run()
      /go/pkg/mod/golang.org/x/[email protected]/ssh/session.go:310 +0x50
  github.com/appleboy/easyssh-proxy.(*MakeConfig).Scp()
      /go/pkg/mod/github.com/appleboy/[email protected]/easyssh.go:356 +0x2e0
....

Previous read at 0x00c000397240 by goroutine 72:
  golang.org/x/crypto/ssh.(*Session).StdinPipe()
      /go/pkg/mod/golang.org/x/[email protected]/ssh/session.go:545 +0x3d7
  github.com/appleboy/easyssh-proxy.(*MakeConfig).Scp.func1()
      /go/pkg/mod/github.com/appleboy/[email protected]/easyssh.go:339 +0x7c
@july2993
Copy link
Contributor Author

@appleboy PTAL

@appleboy appleboy added the bug label Apr 27, 2020
@appleboy appleboy self-requested a review April 27, 2020 14:49
@appleboy appleboy merged commit bbb1a80 into appleboy:master Apr 28, 2020
@appleboy
Copy link
Owner

bump to v1.3.2 and thanks @july2993

@july2993 july2993 deleted the fix_race branch April 28, 2020 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants