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

fix(tm2): rpc unhandled panic #711

Merged
merged 3 commits into from
Apr 18, 2023
Merged

Conversation

tbruyelle
Copy link
Contributor

Description

When panic is called with a string argument, that triggers an other panic in the recover handler, because it tries to convert the argument to an error type. Fortunately this second panic is catched by the recover of the stdlib in net/http/server.go, so the node doesn't halt.

How has this been tested?

To trigger the problem, you can run the following command:

$ gnokey query -data xxx vm/qrender
Post "http://127.0.0.1:26657": EOF

Because the handler behind vm/qrender expects to have some data in a particular format and it's not, it panics with a string.

When panic is called with a string argument, that triggers an other
panic in the recover handler, because it tries to convert the argument
to [an error type][1]. Fortunately this second panic is catched by the
recover of the stdlib in [net/http/server.go][0], so the node doesn't
halt.

To trigger the problem, you can run the following command:

```sh
$ gnokey query -data xxx vm/qrender
Post "http://127.0.0.1:26657": EOF
```

Because the handler behind `vm/qrender` expects to have some data in a
particular format and it's not, it [panics with a string][2].

[0]: https://cs.opensource.google/go/go/+/refs/tags/go1.20.3:src/net/http/server.go;l=1851
[1]: https://github.com/gnolang/gno/blob/0eb5ff762eeb7e6b98d1f8afdb1214566352cabf/tm2/pkg/bft/rpc/lib/server/http_server.go#L164
[2]: https://github.com/gnolang/gno/blob/0eb5ff762eeb7e6b98d1f8afdb1214566352cabf/tm2/pkg/sdk/vm/handler.go#L131-L134
@tbruyelle tbruyelle requested a review from a team as a code owner April 6, 2023 17:08
Copy link
Contributor

@jaekwon jaekwon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice and complete

@jaekwon jaekwon merged commit 31dd5be into gnolang:master Apr 18, 2023
peter7891 pushed a commit that referenced this pull request May 9, 2023
* fix(tm2): rpc unhandled panic

When panic is called with a string argument, that triggers an other
panic in the recover handler, because it tries to convert the argument
to [an error type][1]. Fortunately this second panic is catched by the
recover of the stdlib in [net/http/server.go][0], so the node doesn't
halt.

To trigger the problem, you can run the following command:

```sh
$ gnokey query -data xxx vm/qrender
Post "http://127.0.0.1:26657": EOF
```

Because the handler behind `vm/qrender` expects to have some data in a
particular format and it's not, it [panics with a string][2].

[0]: https://cs.opensource.google/go/go/+/refs/tags/go1.20.3:src/net/http/server.go;l=1851
[1]: https://github.com/gnolang/gno/blob/0eb5ff762eeb7e6b98d1f8afdb1214566352cabf/tm2/pkg/bft/rpc/lib/server/http_server.go#L164
[2]: https://github.com/gnolang/gno/blob/0eb5ff762eeb7e6b98d1f8afdb1214566352cabf/tm2/pkg/sdk/vm/handler.go#L131-L134

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

Successfully merging this pull request may close these issues.

3 participants