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

Some kinds of errors are returned as %!s(PANIC=...nil pointer #96

Open
dirkmc opened this issue Mar 1, 2023 · 1 comment
Open

Some kinds of errors are returned as %!s(PANIC=...nil pointer #96

dirkmc opened this issue Mar 1, 2023 · 1 comment

Comments

@dirkmc
Copy link

dirkmc commented Mar 1, 2023

As described in filecoin-project/boost#1193 when go-jsonrpc encounters some errors it turns them into %!s(PANIC=...nil pointer

lotus users have encountered this error message when making API calls that time out:

ERROR: %!s(PANIC=Error method: runtime error: invalid memory address or nil pointer dereference)

The error message is printed out by lotus cli helper when an error is returned from a CLI Action:

fmt.Fprintf(os.Stderr, "ERROR: %s\n\n", err)

The format of the error message %!s(PANIC=...nil pointer indicates that fmt.Fprintf encountered a nil pointer when trying to call the Error() method on the golang error object that was passed to it. This is most likely because the error object wraps a nil error. An example golang Test that reproduces this behaviour:

type myerr struct {
	err error
}

func (e *myerr) Error() string {
	// if e.err is nil, this will panic
	return e.err.Error()
}

func TestPrintErr(t *testing.T) {
	fmt.Printf("%s\n", &myerr{})
}

=== RUN   TestPrintErr
%!s(PANIC=Error method: runtime error: invalid memory address or nil pointer dereference)
--- PASS: TestPrintErr (0.00s)

It looks like the underlying implementation of go-jsonrpc is returning an error object that wraps a nil error. My best guess is that this bug was introduced in #72

@jacobheun
Copy link

Believe this should be fixed in lotus, @dirkmc to confirm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@dirkmc @jacobheun and others