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

gnovm/pkg/transpiler: mangled imports in Gno code cause a panic when generating Go code #3425

Open
odeke-em opened this issue Dec 29, 2024 · 0 comments
Labels
🐞 bug Something isn't working

Comments

@odeke-em
Copy link
Contributor

odeke-em commented Dec 29, 2024

Description

In furtherance of #3087, I am fuzzing and investigating the transpiler and when presented with this Gno program

package A
import(""//"
""/***/)

Passing it into the transpiler results in this panic

panic: invalid line number 5 (should be < 5) [recovered]
	panic: invalid line number 5 (should be < 5)

goroutine 26 [running]:
github.com/gnolang/gno/gnovm/pkg/transpiler.Transpile.func1()
	/home/emmanuel/go/src/github.com/gnolang/gno/gnovm/pkg/transpiler/transpiler.go:131 +0xae
panic({0xb30640?, 0xc0001246c0?})
	/home/emmanuel/go/src/go.googlesource.com/go/src/runtime/panic.go:787 +0x132
go/token.(*File).MergeLine(0xc00028e300, 0x63?)
	/home/emmanuel/go/src/go.googlesource.com/go/src/go/token/position.go:157 +0x1a8
go/ast.sortSpecs(0xc00025e080, 0xc0006c4dc0, {0xc000126e80, 0x2, 0x2})
	/home/emmanuel/go/src/go.googlesource.com/go/src/go/ast/import.go:210 +0xa54
go/ast.SortImports(0xc00025e080, 0xc0006c4dc0)
	/home/emmanuel/go/src/go.googlesource.com/go/src/go/ast/import.go:40 +0x5a7
go/format.Node({0xe56460, 0xc0006a5740}, 0xc00025e080, {0xb6d720?, 0xc0006c4be0?})
	/home/emmanuel/go/src/go.googlesource.com/go/src/go/format/format.go:81 +0x286
github.com/gnolang/gno/gnovm/pkg/transpiler.Transpile({0xc00044f000, 0x1f}, {0xc2c171, 0x3}, {0xc2d99e, 0x6})
	/home/emmanuel/go/src/github.com/gnolang/gno/gnovm/pkg/transpiler/transpiler.go:134 +0x5ef

where it tried to generate this Go code

// Code generated by github.com/gnolang/gno. DO NOT EDIT.

//go:build gno

//line in.gno:1:1

Expected behaviour

Not a panic

Kindly cc-ing @petar-dambovaliev @moul @jaekwon

@odeke-em odeke-em added the 🐞 bug Something isn't working label Dec 29, 2024
@odeke-em odeke-em changed the title gnovm/pkg/transpiler: mangled imports in Gno code cause a panic when generating Go code gnovm/pkg/transpiler: mangled imports in Gno code cause a panic and hung the process when generating Go code Dec 29, 2024
@odeke-em odeke-em changed the title gnovm/pkg/transpiler: mangled imports in Gno code cause a panic and hung the process when generating Go code gnovm/pkg/transpiler: mangled imports in Gno code cause a panic when generating Go code Dec 30, 2024
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
Status: Triage
Development

No branches or pull requests

1 participant