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

println panics on byte pointer types #1575

Closed
deelawn opened this issue Jan 23, 2024 · 1 comment · Fixed by #1601
Closed

println panics on byte pointer types #1575

deelawn opened this issue Jan 23, 2024 · 1 comment · Fixed by #1601
Assignees
Labels
🐞 bug Something isn't working 📦 🤖 gnovm Issues or PRs gnovm related

Comments

@deelawn
Copy link
Contributor

deelawn commented Jan 23, 2024

A panic occurs when trying to print a pointer to a single byte value using println.

This can be produced by running:

package main

func main() {
    c := []byte("A")
    println(&c[0])
}

Trace:

goroutine 19 [running]:
runtime/debug.Stack()
	/usr/local/go/src/runtime/debug/stack.go:24 +0x5e
runtime/debug.PrintStack()
	/usr/local/go/src/runtime/debug/stack.go:16 +0x13
github.com/gnolang/gno/gnovm/tests.RunFileTest.func1.1()
	/Users/dylan/deelawn/gnoland/gno2/gno/gnovm/tests/file.go:136 +0x157
panic({0x17582e0?, 0x1a31990?})
	/usr/local/go/src/runtime/panic.go:914 +0x21f
github.com/gnolang/gno/gnovm/pkg/gnolang.(*TypedValue).ProtectedSprint(0xc000437bc0, 0xc00019d260, 0x0)
	/Users/dylan/deelawn/gnoland/gno2/gno/gnovm/pkg/gnolang/values_string.go:341 +0xdde
github.com/gnolang/gno/gnovm/pkg/gnolang.TypedValue.ProtectedString({{0x1a3b930, 0x1a30778}, {0x1a37918, 0xc0003fb1a0}, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...}}, ...)
...

Note that this does not occur if c is initialized differently:

package main

func main() {
    c := []byte{'A'}
    println(&c[0])
}

This seems to be related to #1569 where the behavior changes depending how the byte slice was initialized. However, I think that the solution here may be to account for the DataByteValue type in TypedValue's ProtectedSprint method.

@deelawn deelawn added 🐞 bug Something isn't working 📦 🤖 gnovm Issues or PRs gnovm related labels Jan 23, 2024
@deelawn deelawn self-assigned this Jan 23, 2024
@deelawn
Copy link
Contributor Author

deelawn commented Feb 28, 2024

This will be fixed by #1601

@deelawn deelawn linked a pull request Feb 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working 📦 🤖 gnovm Issues or PRs gnovm related
Projects
Development

Successfully merging a pull request may close this issue.

2 participants