Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-5092

Panic on nil buffer writes

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.13.0
    • 0.14.0
    • Go - Library
    • None

    Description

      Whenever a buffer from a THttpClient is set to nil, any subsequent attempts to write to the connection will result in a panic.

      Regardless of how the buffer ended up in a nil state, it is a better approach to handle the error in the call to the Write than to have the program panic.

      We've been hitting this issue once in a while and it's been difficult to replicate but here is some sanitized relevant stack trace:

       

       panic(0x1446380, 0x1fcff90)
       	/usr/local/go/src/runtime/panic.go:491 +0x283
       bytes.(*Buffer).Write(0x0, 0xc42143b000, 0x87, 0x1000, 0x1, 0x0, 0x0)
       	/usr/local/go/src/bytes/buffer.go:160 +0x26
       github.company.com/project/internal-project-prod/vendor/github.com/apache/thrift/lib/go/thrift.(*THttpClient).Write(0xc421418b00, 0xc42143b000, 0x87, 0x1000, 0xc421018538, 0x9195a8, 0xc42085ae10)
       	/go/src/github.company.com/project/internal-project-prod/vendor/github.com/apache/thrift/lib/go/thrift/http_client.go:173 +0x4d
       bufio.(*Writer).Flush(0xc421418b80, 0x90f42e, 0xc42085ae10)
       	/usr/local/go/src/bufio/bufio.go:567 +0x7e
       github.company.com/project/internal-project-prod/vendor/github.com/apache/thrift/lib/go/thrift.(*TJSONProtocol).Flush(0xc4203562d0, 0x1f8d4c0, 0xc420016088, 0x0, 0x0)
       	/go/src/github.company.com/project/internal-project-prod/vendor/github.com/apache/thrift/lib/go/thrift/json_protocol.go:440 +0x36
       github.company.com/project/internal-project-prod/vendor/github.com/apache/thrift/lib/go/thrift.(*TStandardClient).Send(0xc420e55020, 0x1f8d4c0, 0xc420016088, 0x1f9b720, 0xc4203562d0, 0x11, 0x1655325, 0xe, 0x1f7f500, 0xc420360020, ...)
      

      followed by the root cause of the panic:

      runtime error: invalid memory address or nil pointer dereference
      

      I have a patch I'm testing out. I would love some feedback on it.

      https://github.com/apache/thrift/compare/master...ridv:0.12.0

       

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            renan Renan DelValle
            renan Renan DelValle
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m

                Slack

                  Issue deployment