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

fmt: stack overflow #11099

Closed
9yx opened this issue Jun 6, 2015 · 1 comment
Closed

fmt: stack overflow #11099

9yx opened this issue Jun 6, 2015 · 1 comment

Comments

@9yx
Copy link

@9yx 9yx commented Jun 6, 2015

Run code:

package main

import "fmt"

func main() {
    var a []interface{}
    a = make([]interface{}, 0, 10)
    a = append(a,
        append(a, 2, 3, 4),
        append(a, 5, 6, 7),
        append(a, 8, 9, 10),
        append(a, 11, 12, 13))
    fmt.Println(a)
}

error:

runtime: goroutine stack exceeds 1000000000-byte limit
fatal error: stack overflow

runtime stack:
runtime.throw(0x514cd0, 0xe)
        /opt/go.1.5/src/runtime/panic.go:527 +0x96
runtime.newstack()
        /opt/go.1.5/src/runtime/stack1.go:778 +0xb45
runtime.morestack()
        /opt/go.1.5/src/runtime/asm_amd64.s:330 +0x82

goroutine 1 [stack growth]:
fmt.(*pp).printReflectValue(0xc208070410, 0x4be620, 0xc20800e0a0, 0xd4, 0xc200000076, 0x3b25d, 0x0)
        /opt/go.1.5/src/fmt/print.go:850 fp=0xc2280c6488 sp=0xc2280c6480
fmt.(*pp).printValue(0xc208070410, 0x4be620, 0xc20800e0a0, 0xd4, 0x76, 0x3b25d, 0xd4)
        /opt/go.1.5/src/fmt/print.go:843 +0x440 fp=0xc2280c6578 sp=0xc2280c6488
fmt.(*pp).printReflectValue(0xc208070410, 0x4b9a00, 0xc2080104e0, 0x57, 0xc200000076, 0x3b25c, 0x0)
        /opt/go.1.5/src/fmt/print.go:985 +0x13e3 fp=0xc2280c6d30 sp=0xc2280c6578
fmt.(*pp).printValue(0xc208070410, 0x4b9a00, 0xc2080104e0, 0x57, 0xc200000076, 0x3b25c, 0x0)
        /opt/go.1.5/src/fmt/print.go:843 +0x440 fp=0xc2280c6e20 sp=0xc2280c6d30
fmt.(*pp).printReflectValue(0xc208070410, 0x4be620, 0xc20800e0a0, 0xd4, 0xc200000076, 0x3b25b, 0x0)
        /opt/go.1.5/src/fmt/print.go:940 +0x209e fp=0xc2280c75d8 sp=0xc2280c6e20
fmt.(*pp).printValue(0xc208070410, 0x4be620, 0xc20800e0a0, 0xd4, 0x76, 0x3b25b, 0xd4)
        /opt/go.1.5/src/fmt/print.go:843 +0x440 fp=0xc2280c76c8 sp=0xc2280c75d8

I think error should return error of println (or add to the documentation of the stack overflow in fmt)

@ALTree
Copy link
Member

@ALTree ALTree commented Jun 6, 2015

This is #8241 and this behaviour is documented

Infinite recursion can also be triggered by self-referential data structures, such as a slice that contains itself as an element, if that type has a String method. Such pathologies are rare, however, and the package does not protect against them.

here.

@9yx 9yx closed this Jun 6, 2015
@mikioh mikioh changed the title fmt stack overflow fmt: stack overflow Jun 6, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.