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

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

Closed
Osipion opened this issue Jul 12, 2021 · 3 comments · Fixed by #322
Closed

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

Osipion opened this issue Jul 12, 2021 · 3 comments · Fixed by #322
Labels
bug Something isn't working

Comments

@Osipion
Copy link

Osipion commented Jul 12, 2021

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/go-flow-levee@v0.1.5/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/go-flow-levee@v0.1.5/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/go-flow-levee@v0.1.5/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/go-flow-levee@v0.1.5/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/go-flow-levee@v0.1.5/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/go-flow-levee@v0.1.5/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/go-flow-levee@v0.1.5/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/go-flow-levee@v0.1.5/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/go-flow-levee@v0.1.5/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/go-flow-levee@v0.1.5/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/go-flow-levee@v0.1.5/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/go-flow-levee@v0.1.5/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/go-flow-levee@v0.1.5/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)
@Osipion Osipion added the bug Something isn't working label Jul 12, 2021
@mlevesquedion
Copy link
Contributor

Thank you for filing this bug report!

I've opened a PR which will fix this issue.

@Osipion
Copy link
Author

Osipion commented Jul 13, 2021

Thanks @mlevesquedion - do you know when this patch will hit a release?

@mlevesquedion
Copy link
Contributor

Here you go: https://github.com/google/go-flow-levee/releases/tag/v0.1.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants