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

Basic typo in cli causes segfault #1250

Open
Tjstretchalot opened this issue May 5, 2023 · 2 comments
Open

Basic typo in cli causes segfault #1250

Tjstretchalot opened this issue May 5, 2023 · 2 comments

Comments

@Tjstretchalot
Copy link

What version are you running?
Version v7.14.3, commit fa7fc71, branch master, built on 2023-04-25T19:28:17-0400

I believe this issue goes back at least to v7.13.0, but probably earlier

Are you using Docker or Kubernetes to run your system?
No

Are you running a single node or a cluster?
Single node

What did you do?
Sometimes I accidentally add two semicolons at the end of a query, e.g., select 1;; in the command-line interface (rqlite)

What did you expect to happen?
The semicolons are ignored and the program outputs

+---+
| 1 |
+---+
| 1 |
+---+

What happened instead?
Hangs for a second, segfaults, and the server dies

127.0.0.1:4001> select 1;;
[client] 2023/05/05 10:47:34 host '127.0.0.1:4001' is unavailable, retrying with the next available host
[client] 2023/05/05 10:47:34 host '' is unavailable, retrying with the next available host
[client] 2023/05/05 10:47:34 none of the available hosts are responsive
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x694a15]

goroutine 1 [running]:
main.main.func1(0xc00015e370)
        /tmp/tmp.OX40vNVWIX/src/github.com/rqlite/rqlite/cmd/rqlite/main.go:203 +0x12b5
github.com/mkideal/cli.(*Command).RunWith(0xc00014e360, {0xc00011e240, 0x0, 0x0}, {0x0?, 0x0?}, {0x0, 0x0}, {0x0, 0x0, ...})
        /tmp/tmp.OX40vNVWIX/pkg/mod/github.com/mkideal/cli@v0.2.7/command.go:219 +0x399
github.com/mkideal/cli.(*Command).Run(...)
        /tmp/tmp.OX40vNVWIX/pkg/mod/github.com/mkideal/cli@v0.2.7/command.go:176
github.com/mkideal/cli.RunWithArgs({0x6c2740?, 0xc0001d4000?}, {0xc00011e240?, 0x1?, 0x1?}, 0x740dc0?, {0x0?, 0x6b6c80?, 0xc000002340?})
        /tmp/tmp.OX40vNVWIX/pkg/mod/github.com/mkideal/cli@v0.2.7/cli.go:30 +0x230
github.com/mkideal/cli.Run(...)
        /tmp/tmp.OX40vNVWIX/pkg/mod/github.com/mkideal/cli@v0.2.7/cli.go:15
main.main()
        /tmp/tmp.OX40vNVWIX/src/github.com/rqlite/rqlite/cmd/rqlite/main.go:62 +0x5e

Please include the Status, Nodes, and Expvar output from each node (or at least the Leader!)
Since the rqlite node completely crashess and the client segfaults, this isn't applicable. This is also 100% repeatable on a fresh node

Additional Notes
I assume that there is some chance of this corrupting a cluster if done as a strong-level query or during an insert/update, but I haven't tested to confirm.

@otoolep
Copy link
Member

otoolep commented May 5, 2023

Thanks for the report, I just ran a quick test and I think this is in the lowest DB levels of rqlite (which I don't write). I'm surprised no one hit this before! It may be a regression in https://github.com/mattn/go-sqlite3

@otoolep
Copy link
Member

otoolep commented May 5, 2023

Yeah, the CLI should handle this more gracefully but if you hit the API of rqlite directly it server blows up. Not good, not good at all. I'll push on the maintainers of the upstream repo to look into this.

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

2 participants