Skip to content

Stack Overflow in internal/pkg/sourcetype/sourcetype.go #320

@Osipion

Description

@Osipion

Bug report

Describe the bug
There appears to be a stack overflow in internal/pkg/sourcetype/sourcetype.go, as a result of infinite recursion between line 36 and line 45 (checking whether type.Named type is a source type and checking whether a map element is a source type). This may be triggered by creating a named map type where which stores elements of its own type.

To Reproduce
Run go-flow-levee on the following code:

package main

type Tree map[string]Tree

func main() {
	_ = make(Tree)
}

Additional context
Stacktrace:

runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0xc02288e470 stack=[0xc02288e000, 0xc04288e000]
fatal error: stack overflow

runtime stack:
runtime.throw(0x1424e9f, 0xe)
        /usr/local/opt/go/libexec/src/runtime/panic.go:1116 +0x72
runtime.newstack()
        /usr/local/opt/go/libexec/src/runtime/stack.go:1060 +0x78d
runtime.morestack()
        /usr/local/opt/go/libexec/src/runtime/asm_amd64.s:449 +0x8f

goroutine 6 [running]:
github.com/google/go-flow-levee/internal/pkg/sourcetype.IsSourceType(0xc0001bc2d0, 0xc0010f8120, 0x1497a00, 0xc000677c20, 0x0)
        /base/go/pkg/mod/github.com/google/[email protected]/internal/pkg/sourcetype/sourcetype.go:32 +0x5db fp=0xc02288e480 sp=0xc02288e478 pc=0x12915db
github.com/google/go-flow-levee/internal/pkg/sourcetype.IsSourceType(0xc0001bc2d0, 0xc0010f8120, 0x1497a40, 0xc00068b7c0, 0x0)
        /base/go/pkg/mod/github.com/google/[email protected]/internal/pkg/sourcetype/sourcetype.go:36 +0x5b6 fp=0xc02288e608 sp=0xc02288e480 pc=0x12915b6
github.com/google/go-flow-levee/internal/pkg/sourcetype.IsSourceType(0xc0001bc2d0, 0xc0010f8120, 0x1497a00, 0xc000677c20, 0x0)
        /base/go/pkg/mod/github.com/google/[email protected]/internal/pkg/sourcetype/sourcetype.go:45 +0x24f fp=0xc02288e790 sp=0xc02288e608 pc=0x129124f
github.com/google/go-flow-levee/internal/pkg/sourcetype.IsSourceType(0xc0001bc2d0, 0xc0010f8120, 0x1497a40, 0xc00068b7c0, 0x0)
        /base/go/pkg/mod/github.com/google/[email protected]/internal/pkg/sourcetype/sourcetype.go:36 +0x5b6 fp=0xc02288e918 sp=0xc02288e790 pc=0x12915b6
github.com/google/go-flow-levee/internal/pkg/sourcetype.IsSourceType(0xc0001bc2d0, 0xc0010f8120, 0x1497a00, 0xc000677c20, 0x0)
        /base/go/pkg/mod/github.com/google/[email protected]/internal/pkg/sourcetype/sourcetype.go:45 +0x24f fp=0xc02288eaa0 sp=0xc02288e918 pc=0x129124f
github.com/google/go-flow-levee/internal/pkg/sourcetype.IsSourceType(0xc0001bc2d0, 0xc0010f8120, 0x1497a40, 0xc00068b7c0, 0x0)
        /base/go/pkg/mod/github.com/google/[email protected]/internal/pkg/sourcetype/sourcetype.go:36 +0x5b6 fp=0xc02288ec28 sp=0xc02288eaa0 pc=0x12915b6
github.com/google/go-flow-levee/internal/pkg/sourcetype.IsSourceType(0xc0001bc2d0, 0xc0010f8120, 0x1497a00, 0xc000677c20, 0x0)
        /base/go/pkg/mod/github.com/google/[email protected]/internal/pkg/sourcetype/sourcetype.go:45 +0x24f fp=0xc02288edb0 sp=0xc02288ec28 pc=0x129124f
github.com/google/go-flow-levee/internal/pkg/sourcetype.IsSourceType(0xc0001bc2d0, 0xc0010f8120, 0x1497a40, 0xc00068b7c0, 0x0)
        /base/go/pkg/mod/github.com/google/[email protected]/internal/pkg/sourcetype/sourcetype.go:36 +0x5b6 fp=0xc02288ef38 sp=0xc02288edb0 pc=0x12915b6
github.com/google/go-flow-levee/internal/pkg/sourcetype.IsSourceType(0xc0001bc2d0, 0xc0010f8120, 0x1497a00, 0xc000677c20, 0x0)
        /base/go/pkg/mod/github.com/google/[email protected]/internal/pkg/sourcetype/sourcetype.go:45 +0x24f fp=0xc02288f0c0 sp=0xc02288ef38 pc=0x129124f
github.com/google/go-flow-levee/internal/pkg/sourcetype.IsSourceType(0xc0001bc2d0, 0xc0010f8120, 0x1497a40, 0xc00068b7c0, 0x0)
        /base/go/pkg/mod/github.com/google/[email protected]/internal/pkg/sourcetype/sourcetype.go:36 +0x5b6 fp=0xc02288f248 sp=0xc02288f0c0 pc=0x12915b6
github.com/google/go-flow-levee/internal/pkg/sourcetype.IsSourceType(0xc0001bc2d0, 0xc0010f8120, 0x1497a00, 0xc000677c20, 0x0)
        /base/go/pkg/mod/github.com/google/[email protected]/internal/pkg/sourcetype/sourcetype.go:45 +0x24f fp=0xc02288f3d0 sp=0xc02288f248 pc=0x129124f
github.com/google/go-flow-levee/internal/pkg/sourcetype.IsSourceType(0xc0001bc2d0, 0xc0010f8120, 0x1497a40, 0xc00068b7c0, 0x0)
        /base/go/pkg/mod/github.com/google/[email protected]/internal/pkg/sourcetype/sourcetype.go:36 +0x5b6 fp=0xc02288f558 sp=0xc02288f3d0 pc=0x12915b6
github.com/google/go-flow-levee/internal/pkg/sourcetype.IsSourceType(0xc0001bc2d0, 0xc0010f8120, 0x1497a00, 0xc000677c20, 0x0)
        /base/go/pkg/mod/github.com/google/[email protected]/internal/pkg/sourcetype/sourcetype.go:45 +0x24f fp=0xc02288f6e0 sp=0xc02288f558 pc=0x129124f
github.com/google/go-flow-levee/internal/pkg/sourcetype.IsSourceType(0xc0001bc2d0, 0xc0010f8120, 0x1497a40, 0xc00068b7c0, 0x0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions