Skip to content

Fix Ping data-race#91

Merged
dmcgowan merged 1 commit into
moby:masterfrom
tigrato:fix-ping-data-race
Jun 21, 2024
Merged

Fix Ping data-race#91
dmcgowan merged 1 commit into
moby:masterfrom
tigrato:fix-ping-data-race

Conversation

@tigrato

@tigrato tigrato commented May 6, 2023

Copy link
Copy Markdown
Contributor

While testing some code under -race flag, the race detector flagged a data race on spdystream.Ping code path.

==================
WARNING: DATA RACE
Read at 0x00c012a966a8 by goroutine 483923:
  github.com/moby/spdystream.(*Connection).handlePingFrame()
      /go/pkg/mod/github.com/moby/spdystream@v0.2.0/connection.go:615 +0x3e
  github.com/moby/spdystream.(*Connection).frameHandler()
      /go/pkg/mod/github.com/moby/spdystream@v0.2.0/connection.go:432 +0x144
  github.com/moby/spdystream.(*Connection).Serve.func2()
      /go/pkg/mod/github.com/moby/spdystream@v0.2.0/connection.go:331 +0xa6
  github.com/moby/spdystream.(*Connection).Serve.func4()
      /go/pkg/mod/github.com/moby/spdystream@v0.2.0/connection.go:332 +0x47

Previous write at 0x00c012a966a8 by goroutine 483918:
  github.com/moby/spdystream.(*Connection).Ping()
      /go/pkg/mod/github.com/moby/spdystream@v0.2.0/connection.go:281 +0x117
  github.com/moby/spdystream.(*Connection).Ping-fm()
      <autogenerated>:1 +0x39
  k8s.io/apimachinery/pkg/util/httpstream/spdy.(*connection).sendPings()
      /go/pkg/mod/k8s.io/apimachinery@v0.26.3/pkg/util/httpstream/spdy/connection.go:197 +0x1b6
  k8s.io/apimachinery/pkg/util/httpstream/spdy.newConnection.func2()
      /go/pkg/mod/k8s.io/apimachinery@v0.26.3/pkg/util/httpstream/spdy/connection.go:96 +0x47

Goroutine 483923 (running) created at:
  github.com/moby/spdystream.(*Connection).Serve()
      /go/pkg/mod/github.com/moby/spdystream@v0.2.0/connection.go:327 +0x9e
  k8s.io/apimachinery/pkg/util/httpstream/spdy.newConnection.func1()
      /go/pkg/mod/k8s.io/apimachinery@v0.26.3/pkg/util/httpstream/spdy/connection.go:94 +0x47

Goroutine 483918 (running) created at:
  k8s.io/apimachinery/pkg/util/httpstream/spdy.newConnection()
      /go/pkg/mod/k8s.io/apimachinery@v0.26.3/pkg/util/httpstream/spdy/connection.go:96 +0x34d
  k8s.io/apimachinery/pkg/util/httpstream/spdy.NewClientConnectionWithPings()
      /go/pkg/mod/k8s.io/apimachinery@v0.26.3/pkg/util/httpstream/spdy/connection.go:57 +0x224
  k8s.io/apimachinery/pkg/util/httpstream/spdy.(*SpdyRoundTripper).NewConnection()
      /go/pkg/mod/k8s.io/apimachinery@v0.26.3/pkg/util/httpstream/spdy/roundtripper.go:357 +0x644
  k8s.io/client-go/transport/spdy.Negotiate()
      /go/pkg/mod/k8s.io/client-go@v0.26.3/transport/spdy/spdy.go:98 +0x42d
  k8s.io/client-go/tools/remotecommand.(*streamExecutor).newConnectionAndStream()
      /go/pkg/mod/k8s.io/client-go@v0.26.3/tools/remotecommand/remotecommand.go:125 +0x2d7
  k8s.io/client-go/tools/remotecommand.(*streamExecutor).StreamWithContext()
      /go/pkg/mod/k8s.io/client-go@v0.26.3/tools/remotecommand/remotecommand.go:157 +0xbc
==================

This PR aims to fix the present data race

@tigrato tigrato force-pushed the fix-ping-data-race branch from 01643f3 to ed81dbd Compare May 6, 2023 14:11
While testing some code under `-race` flag, the race detector flagged a
data race on `spdystream.Ping` code path.

```
==================
WARNING: DATA RACE
Read at 0x00c012a966a8 by goroutine 483923:
  github.com/moby/spdystream.(*Connection).handlePingFrame()
      /go/pkg/mod/github.com/moby/spdystream@v0.2.0/connection.go:615 +0x3e
  github.com/moby/spdystream.(*Connection).frameHandler()
      /go/pkg/mod/github.com/moby/spdystream@v0.2.0/connection.go:432 +0x144
  github.com/moby/spdystream.(*Connection).Serve.func2()
      /go/pkg/mod/github.com/moby/spdystream@v0.2.0/connection.go:331 +0xa6
  github.com/moby/spdystream.(*Connection).Serve.func4()
      /go/pkg/mod/github.com/moby/spdystream@v0.2.0/connection.go:332 +0x47

Previous write at 0x00c012a966a8 by goroutine 483918:
  github.com/moby/spdystream.(*Connection).Ping()
      /go/pkg/mod/github.com/moby/spdystream@v0.2.0/connection.go:281 +0x117
  github.com/moby/spdystream.(*Connection).Ping-fm()
      <autogenerated>:1 +0x39
  k8s.io/apimachinery/pkg/util/httpstream/spdy.(*connection).sendPings()
      /go/pkg/mod/k8s.io/apimachinery@v0.26.3/pkg/util/httpstream/spdy/connection.go:197 +0x1b6
  k8s.io/apimachinery/pkg/util/httpstream/spdy.newConnection.func2()
      /go/pkg/mod/k8s.io/apimachinery@v0.26.3/pkg/util/httpstream/spdy/connection.go:96 +0x47

Goroutine 483923 (running) created at:
  github.com/moby/spdystream.(*Connection).Serve()
      /go/pkg/mod/github.com/moby/spdystream@v0.2.0/connection.go:327 +0x9e
  k8s.io/apimachinery/pkg/util/httpstream/spdy.newConnection.func1()
      /go/pkg/mod/k8s.io/apimachinery@v0.26.3/pkg/util/httpstream/spdy/connection.go:94 +0x47

Goroutine 483918 (running) created at:
  k8s.io/apimachinery/pkg/util/httpstream/spdy.newConnection()
      /go/pkg/mod/k8s.io/apimachinery@v0.26.3/pkg/util/httpstream/spdy/connection.go:96 +0x34d
  k8s.io/apimachinery/pkg/util/httpstream/spdy.NewClientConnectionWithPings()
      /go/pkg/mod/k8s.io/apimachinery@v0.26.3/pkg/util/httpstream/spdy/connection.go:57 +0x224
  k8s.io/apimachinery/pkg/util/httpstream/spdy.(*SpdyRoundTripper).NewConnection()
      /go/pkg/mod/k8s.io/apimachinery@v0.26.3/pkg/util/httpstream/spdy/roundtripper.go:357 +0x644
  k8s.io/client-go/transport/spdy.Negotiate()
      /go/pkg/mod/k8s.io/client-go@v0.26.3/transport/spdy/spdy.go:98 +0x42d
  k8s.io/client-go/tools/remotecommand.(*streamExecutor).newConnectionAndStream()
      /go/pkg/mod/k8s.io/client-go@v0.26.3/tools/remotecommand/remotecommand.go:125 +0x2d7
  k8s.io/client-go/tools/remotecommand.(*streamExecutor).StreamWithContext()
      /go/pkg/mod/k8s.io/client-go@v0.26.3/tools/remotecommand/remotecommand.go:157 +0xbc
==================
```

This PR aims to fix the present data race.

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
@tigrato

tigrato commented May 8, 2023

Copy link
Copy Markdown
Contributor Author

@thaJeztah @dims PTAL

@tigrato

tigrato commented Jul 22, 2023

Copy link
Copy Markdown
Contributor Author

@thaJeztah @dims any update on this one?

@bertoldia

Copy link
Copy Markdown

Howdy @dmcgowan @tigrato @thaJeztah 👋 Is there any reason this PR has not been merged yet? It's been approved for over 6 months. The bug is impacting other systems (e.g. https://gitlab.com/gitlab-org/gitlab-runner/-/issues/31077). What's missing to get this merged? 🙇

@tigrato

tigrato commented Mar 19, 2024

Copy link
Copy Markdown
Contributor Author

Howdy @dmcgowan @tigrato @thaJeztah 👋 Is there any reason this PR has not been merged yet? It's been approved for over 6 months. The bug is impacting other systems (e.g. https://gitlab.com/gitlab-org/gitlab-runner/-/issues/31077). What's missing to get this merged? 🙇

I am waiting for someone with write access to merge the PR.

At gravitational, we keep a fork of this library https://github.com/gravitational/spdystream (branch is teleport) where we included this fix to avoid having crashes and several data races flagged during tests.

@bertoldia

Copy link
Copy Markdown

Thanks @tigrato 👍

@puertomontt

Copy link
Copy Markdown

ran into this as well. Is this repo dead?

@dmcgowan

Copy link
Copy Markdown
Member

This project is open source, feel free to add reviews. Especially if you have a fork and verified the change, thats valuable for determining the change is good. This project is very inactive so its hard to be confident a change is ready to merge. I prefer waiting until multiple reviews to hit the merge button.

gitlab-runner-bot pushed a commit to gitlabhq/gitlab-runner that referenced this pull request Jun 22, 2024
Over in
https://gitlab.com/gitlab-org/gitlab-runner/-/merge_requests/4685 we
switches to using a fork of spdystream because there was an unfixed bug
in upstream that caused a data race in the `Ping` API.

The fork with the fix has now been merged back into upstream now
(moby/spdystream#91), so we can go back to using
upstream.
tigrato added a commit to gravitational/teleport that referenced this pull request Jun 26, 2024
this PR drops the go.mod replace directive from `github.com/moby/spdystream` now that moby/spdystream#91 was finally merged.

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
github-merge-queue Bot pushed a commit to gravitational/teleport that referenced this pull request Jun 26, 2024
* drop internal `spdystream` fork

this PR drops the go.mod replace directive from `github.com/moby/spdystream` now that moby/spdystream#91 was finally merged.

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>

* run gomod tidy on every module

---------

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
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

Successfully merging this pull request may close these issues.

4 participants