Skip to content

[BUG] panic for fmt.Fprintf #6

@dirac-lee

Description

@dirac-lee

Here is a bug.

In render.go:244, fmt.Fprintf will panic if buf's cap is not enough. Maybe you can consider use buf.WriteString() in stead, so that it's cap can grow if needed.

runtime error: makeslice: cap out of range
stack=goroutine 1372 [running]:
runtime/debug.Stack()
	/usr/local/go/src/runtime/debug/stack.go:24 +0x65
github.com/cloudwego/kitex/pkg/remote/trans.(*svrTransHandler).OnRead.func1()
	/opt/tiger/compile_path/pkg/mod/github.com/cloudwego/[email protected]/pkg/remote/trans/default_server_handler.go:125 +0xcb
panic({0x34c0ac0, 0x3ec5970})
	/usr/local/go/src/runtime/panic.go:838 +0x207
strconv.appendQuotedWith({0xc000832c98, 0x0, 0x2?}, {0x0, 0xb2bd099e05210e}, 0x22, 0xc2?, 0x47?)
	/usr/local/go/src/strconv/quote.go:35 +0x86
strconv.AppendQuote(...)
	/usr/local/go/src/strconv/quote.go:135
fmt.(*fmt).fmtQ(0xc000832c70, {0x0, 0x8?})
	/usr/local/go/src/fmt/format.go:457 +0xe8
fmt.(*pp).fmtString(0xc00147c278?, {0x0?, 0x1a0?}, 0x1a0?)
	/usr/local/go/src/fmt/print.go:452 +0x3a
fmt.(*pp).printArg(0xc000832c30, {0x33cde00?, 0xc0029b9bf0}, 0x71)
	/usr/local/go/src/fmt/print.go:694 +0x60c
fmt.(*pp).doPrintf(0xc000832c30, {0x38910b2, 0x2}, {0xc00147c580?, 0x1, 0x1})
	/usr/local/go/src/fmt/print.go:1026 +0x288
fmt.Fprintf({0x3ec6140, 0xc000d8a6c0}, {0x38910b2, 0x2}, {0xc00147c580, 0x1, 0x1})
	/usr/local/go/src/fmt/print.go:204 +0x75
github.com/luci/go-render/render.(*traverseState).render(0xc00147caf8, 0xc0013cb2c0?, 0x1, {0x33cde00?, 0xc000b91ff8?, 0x0?}, 0x0)
	/opt/tiger/compile_path/pkg/mod/github.com/luci/[email protected]/render/render.go:244 +0xe4f

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions