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

DATA RACE in resty's middleware (go-resty/resty/v2.releaseBuffer()) #739

Closed
1713266 opened this issue Oct 25, 2023 · 2 comments
Closed

DATA RACE in resty's middleware (go-resty/resty/v2.releaseBuffer()) #739

1713266 opened this issue Oct 25, 2023 · 2 comments
Labels

Comments

@1713266
Copy link

1713266 commented Oct 25, 2023

We detected a data race in resty's middleware when releasing/resetting the buffer. Please check.

Go Version: 1.21.1
Resty Version: v2.10.0

==================
WARNING: DATA RACE
Read at 0x00c001e91ce0 by goroutine 537694:
  bytes.(*Buffer).Reset()
      /home/fwkadmin/.ift/import/content/go-1.21.1-bin-linuxx86_64/go/src/bytes/buffer.go:107 +0x46
  github.com/go-resty/resty/v2.releaseBuffer()
      /testDirectory/vendor/github.com/go-resty/resty/v2/util.go:298 +0x41
  github.com/go-resty/resty/v2.handleRequestBody()
      /testDirectory/vendor/github.com/go-resty/resty/v2/middleware.go:484 +0x6e
  github.com/go-resty/resty/v2.parseRequestBody()
      /testDirectory/vendor/github.com/go-resty/resty/v2/middleware.go:193 +0x290
  github.com/go-resty/resty/v2.(*Client).execute()
      /testDirectory/vendor/github.com/go-resty/resty/v2/client.go:1164 +0x550
  github.com/go-resty/resty/v2.(*Request).Execute.func2()
     /testDirectory/vendor/github.com/go-resty/resty/v2/request.go:947 +0x179
  github.com/go-resty/resty/v2.Backoff()
     /testDirectory/vendor/github.com/go-resty/resty/v2/retry.go:115 +0x1d5
  github.com/go-resty/resty/v2.(*Request).Execute()
      /testDirectory/vendor/github.com/go-resty/resty/v2/request.go:941 +0xac4
  github.com/go-resty/resty/v2.(*Request).Post()
      /testDirectory/vendor/github.com/go-resty/resty/v2/request.go:862 +0x344
  github.wdf.sap.corp/ift/sl-core/pkg/slp/client.sumHandler.sendUserInput()
      /testDirectory/vendor/github.wdf.sap.corp/ift/sl-core/pkg/slp/client/sum_handler.go:69 +0x2cf
  github.wdf.sap.corp/ift/sl-core/pkg/slp/client.(*sumHandler).sendUserInput()
      <autogenerated>:1 +0x84
  github.wdf.sap.corp/ift/sl-core/pkg/slp/client.(*Client).SendUserInput()
      /testDirectory/vendor/github.wdf.sap.corp/ift/sl-core/pkg/slp/client/slp_client.go:536 +0x119e
  github.wdf.sap.corp/ift/slocon/pkg/task/slpclient.FinishedResponse.evaluate()
      /testDirectory/pkg/task/slpclient/onstatefinished.go:160 +0x10a2
  github.wdf.sap.corp/ift/slocon/pkg/task/slpclient.(*dialogHandler).evaluateResponses()
      /testDirectory/pkg/task/slpclient/dialogHandler.go:685 +0x977
  github.wdf.sap.corp/ift/slocon/pkg/task/slpclient.(*dialogHandler).onMessagebox()
      /testDirectory/pkg/task/slpclient/dialogHandler.go:615 +0x3cb
  github.wdf.sap.corp/ift/slocon/pkg/task/slpclient.(*dialogHandler).OnStateDialog()
      /testDirectory/pkg/task/slpclient/dialogHandler.go:592 +0x2cd
  github.wdf.sap.corp/ift/sl-core/pkg/slp/client.(*Loop).Poll()
      /testDirectory/vendor/github.wdf.sap.corp/ift/sl-core/pkg/slp/client/loop.go:319 +0x1f85
  github.wdf.sap.corp/ift/sl-core/pkg/slp/client.(*Loop).Run.func1()
      /testDirectory/vendor/github.wdf.sap.corp/ift/sl-core/pkg/slp/client/loop.go:191 +0x107

Previous write at 0x00c001e91ce0 by goroutine 537693:
  bytes.(*Buffer).Reset()
      /home/fwkadmin/.ift/import/content/go-1.21.1-bin-linuxx86_64/go/src/bytes/buffer.go:107 +0x50
  github.com/go-resty/resty/v2.releaseBuffer()
      /testDirectory/vendor/github.com/go-resty/resty/v2/util.go:298 +0x41
  github.com/go-resty/resty/v2.(*requestBodyReleaser).Close.func1()
      /testDirectory/vendor/github.com/go-resty/resty/v2/util.go:325 +0x45
  sync.(*Once).doSlow()
      /home/fwkadmin/.ift/import/content/go-1.21.1-bin-linuxx86_64/go/src/sync/once.go:74 +0xf0
  sync.(*Once).Do()
      /home/fwkadmin/.ift/import/content/go-1.21.1-bin-linuxx86_64/go/src/sync/once.go:65 +0x44
  github.com/go-resty/resty/v2.(*requestBodyReleaser).Close()
      /testDirectory/vendor/github.com/go-resty/resty/v2/util.go:324 +0x7d
  net/http.(*readTrackingBody).Close()
      /home/fwkadmin/.ift/import/content/go-1.21.1-bin-linuxx86_64/go/src/net/http/transport.go:658 +0x4f
  net/http.(*transferWriter).writeBody.func1()
      /home/fwkadmin/.ift/import/content/go-1.21.1-bin-linuxx86_64/go/src/net/http/transfer.go:343 +0x9a
  runtime.deferreturn()
      /home/fwkadmin/.ift/import/content/go-1.21.1-bin-linuxx86_64/go/src/runtime/panic.go:477 +0x30
  net/http.(*Request).write()
      /home/fwkadmin/.ift/import/content/go-1.21.1-bin-linuxx86_64/go/src/net/http/request.go:738 +0x12cc
  net/http.(*persistConn).writeLoop()
      /home/fwkadmin/.ift/import/content/go-1.21.1-bin-linuxx86_64/go/src/net/http/transport.go:2424 +0x312
  net/http.(*Transport).dialConn.func6()
      /home/fwkadmin/.ift/import/content/go-1.21.1-bin-linuxx86_64/go/src/net/http/transport.go:1777 +0x33

Goroutine 537694 (running) created at:
  github.wdf.sap.corp/ift/sl-core/pkg/slp/client.(*Loop).Run()
      /testDirectory/vendor/github.wdf.sap.corp/ift/sl-core/pkg/slp/client/loop.go:173 +0x164
  github.wdf.sap.corp/ift/slocon/pkg/task/slpclient.slpClientClass.Run()
      /testDirectory/pkg/task/slpclient/slpclient.go:163 +0x970
  github.wdf.sap.corp/ift/slocon/pkg/task/slpclient.(*slpClientClass).Run()
      <autogenerated>:1 +0x95
  github.wdf.sap.corp/ift/slocon/pkg/task.(*Task).start.func3()
      /testDirectory/pkg/task/task.go:595 +0x1d4

Goroutine 537693 (finished) created at:
  net/http.(*Transport).dialConn()
      /home/fwkadmin/.ift/import/content/go-1.21.1-bin-linuxx86_64/go/src/net/http/transport.go:1777 +0x256a
  net/http.(*Transport).dialConnFor()
      /home/fwkadmin/.ift/import/content/go-1.21.1-bin-linuxx86_64/go/src/net/http/transport.go:1467 +0x129
  net/http.(*Transport).queueForDial.func1()
      /home/fwkadmin/.ift/import/content/go-1.21.1-bin-linuxx86_64/go/src/net/http/transport.go:1436 +0x44
==================
@jeevatkm
Copy link
Member

@1713266 I think, possibly, the data race is caused by the release buffer method; it has been fixed in #745; could you please check and let me know the outcome?

@jeevatkm jeevatkm removed this from the v2.11.0 Milestone milestone Dec 27, 2023
@1713266
Copy link
Author

1713266 commented Jan 11, 2024

@jeevatkm Since our upgrade to Resty 2.11.0, nothing like this has been observed again. I will close the issue.

@1713266 1713266 closed this as completed Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants