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

rollback StreamRequestBody flag(fix fasthttp panic issue) #1752

Merged
merged 3 commits into from Jan 6, 2023

Conversation

JayChoi1736
Copy link
Contributor

@JayChoi1736 JayChoi1736 commented Jan 5, 2023

Proposed changes

previous panic logs

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0xf6a2bc]

goroutine 108517 [running]:
github.com/valyala/fasthttp.(*firstByteReader).Read(0xc0291b5908?, {0xc02a341fee?, 0x7f88c5c159a8?, 0x200?})
	/go/pkg/mod/github.com/valyala/fasthttp@v1.34.0/server.go:834 +0x5c
bufio.(*Reader).Read(0xc04327a120, {0xc02a341fee, 0x1bd9, 0x1e386b0?})
	/usr/local/src/bufio/bufio.go:222 +0x106
github.com/valyala/fasthttp.(*requestStream).Read(0xc04d60c9c0, {0xc02a341fee?, 0xc0291b57b8?, 0x1e386b0?})
	/go/pkg/mod/github.com/valyala/fasthttp@v1.34.0/streaming.go:75 +0x2e5
github.com/valyala/bytebufferpool.(*ByteBuffer).ReadFrom(0xc0299d9140, {0x1e2eae0, 0xc04d60c9c0})
	/go/pkg/mod/github.com/valyala/bytebufferpool@v1.0.0/bytebuffer.go:45 +0x13e
io.copyBuffer({0x1e2e920, 0xc0299d9140}, {0x1e2eae0, 0xc04d60c9c0}, {0xc0293ca000, 0x1000, 0x1000})
	/usr/local/src/io/io.go:412 +0x14b
io.CopyBuffer({0x1e2e920?, 0xc0299d9140?}, {0x1e2eae0?, 0xc04d60c9c0?}, {0xc0293ca000?, 0xc0430019f0?, 0x2?})
	/usr/local/src/io/io.go:399 +0x3c
github.com/valyala/fasthttp.copyZeroAlloc({0x1e2e920, 0xc0299d9140}, {0x1e2eae0, 0xc04d60c9c0})
	/go/pkg/mod/github.com/valyala/fasthttp@v1.34.0/http.go:1981 +0x7e
github.com/valyala/fasthttp.(*Request).bodyBytes(0xc03bb0d600)
	/go/pkg/mod/github.com/valyala/fasthttp@v1.34.0/http.go:371 +0xec
github.com/valyala/fasthttp.(*Request).Body(0x20?)
	/go/pkg/mod/github.com/valyala/fasthttp@v1.34.0/http.go:671 +0x9e
github.com/valyala/fasthttp.(*RequestCtx).PostBody(...)
	/go/pkg/mod/github.com/valyala/fasthttp@v1.34.0/server.go:1415
github.com/valyala/fasthttp/fasthttpadaptor.ConvertRequest(0xc03bb0d600, 0xc04e9c6ea0, 0x1)
	/go/pkg/mod/github.com/valyala/fasthttp@v1.34.0/fasthttpadaptor/request.go:15 +0x37
github.com/valyala/fasthttp/fasthttpadaptor.NewFastHTTPHandler.func1(0xc03bb0d600)
	/go/pkg/mod/github.com/valyala/fasthttp@v1.34.0/fasthttpadaptor/adaptor.go:50 +0x85
github.com/valyala/fasthttp.TimeoutWithCodeHandler.func1.1()
	/go/pkg/mod/github.com/valyala/fasthttp@v1.34.0/server.go:471 +0x33
created by github.com/valyala/fasthttp.TimeoutWithCodeHandler.func1
panic: runtime error: slice bounds out of range [:4167] with capacity 4096

goroutine 635068 [running]:
bufio.(*Reader).Read(0xc05aa93500, {0xc05b795ff7?, 0x9?, 0x4000?})
	/usr/local/src/bufio/bufio.go:249 +0x2ed
github.com/valyala/fasthttp.(*requestStream).Read(0xc04f278ff0, {0xc05b795ff7?, 0xc0669719d0?, 0xc05b77a000?})
	/go/pkg/mod/github.com/valyala/fasthttp@v1.34.0/streaming.go:75 +0x2e5
github.com/valyala/bytebufferpool.(*ByteBuffer).ReadFrom(0xc041d8bdd0, {0x1e2eae0, 0xc04f278ff0})
	/go/pkg/mod/github.com/valyala/bytebufferpool@v1.0.0/bytebuffer.go:45 +0x13e
io.copyBuffer({0x1e2e920, 0xc041d8bdd0}, {0x1e2eae0, 0xc04f278ff0}, {0xc01c746000, 0x1000, 0x1000})
	/usr/local/src/io/io.go:412 +0x14b
io.CopyBuffer({0x1e2e920?, 0xc041d8bdd0?}, {0x1e2eae0?, 0xc04f278ff0?}, {0xc01c746000?, 0x0?, 0xc0321a7b00?})
	/usr/local/src/io/io.go:399 +0x3c
github.com/valyala/fasthttp.copyZeroAlloc({0x1e2e920, 0xc041d8bdd0}, {0x1e2eae0, 0xc04f278ff0})
	/go/pkg/mod/github.com/valyala/fasthttp@v1.34.0/http.go:1981 +0x7e
github.com/valyala/fasthttp.(*Request).bodyBytes(0xc033e59b80)
	/go/pkg/mod/github.com/valyala/fasthttp@v1.34.0/http.go:371 +0xec
github.com/valyala/fasthttp.(*Request).Body(0x3?)
	/go/pkg/mod/github.com/valyala/fasthttp@v1.34.0/http.go:671 +0x9e
github.com/valyala/fasthttp.(*RequestCtx).PostBody(...)
	/go/pkg/mod/github.com/valyala/fasthttp@v1.34.0/server.go:1415
github.com/valyala/fasthttp/fasthttpadaptor.ConvertRequest(0xc033e59b80, 0xc066971ea0, 0x1)
	/go/pkg/mod/github.com/valyala/fasthttp@v1.34.0/fasthttpadaptor/request.go:15 +0x37
github.com/valyala/fasthttp/fasthttpadaptor.NewFastHTTPHandler.func1(0xc033e59b80)
	/go/pkg/mod/github.com/valyala/fasthttp@v1.34.0/fasthttpadaptor/adaptor.go:50 +0x85
github.com/valyala/fasthttp.TimeoutWithCodeHandler.func1.1()
	/go/pkg/mod/github.com/valyala/fasthttp@v1.34.0/server.go:471 +0x33
created by github.com/valyala/fasthttp.TimeoutWithCodeHandler.func1
	/go/pkg/mod/github.com/valyala/fasthttp@v1.34.0/server.go:470 +0x16b
  • panic occurs when request's bodyStream is not nil and bodyStream reader is broken.
  • test : As a result of applying the patch to the environment where the panic occurred, the same panic did not occur for more than 24 hours
  • still looking for the condition which trigger the panic(= broken bodystream Reader)

Types of changes

Please put an x in the boxes related to your change.

  • Bugfix
  • New feature or enhancement
  • Others

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING GUIDELINES doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes ($ make test)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Related issues

  • Please leave the issue numbers or links related to this PR here.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

@aidan-kwon aidan-kwon mentioned this pull request Jan 5, 2023
Copy link
Contributor

@yoomee1313 yoomee1313 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@JayChoi1736 JayChoi1736 merged commit c27536a into klaytn:dev Jan 6, 2023
blukat29 pushed a commit that referenced this pull request Jan 6, 2023
rollback StreamRequestBody flag(fix fasthttp panic issue)
@blukat29 blukat29 added this to the v1.10.1 milestone Jan 6, 2023
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.

None yet

7 participants