Segfault when running ``headscale nodes list --output json`` when backend is not running. #277

Closed
opened 2025-12-29 01:25:51 +01:00 by adam · 1 comment
Owner

Originally created by @rcmcdonald91 on GitHub (Jun 17, 2022).

When running headscale nodes list --output json against a server that is offline, a segfault is encountered. headscale nodes list fails gracefully with Could not connect..... This segfault is problematic for frontends that consume json output exclusively.

$ headscale nodes list --output json
panic: runtime error: invalid memory address or nil pointer dereference
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0xb1feab]

goroutine 1 [running]:
google.golang.org/grpc.(*ClientConn).Close(0x0)
        google.golang.org/grpc@v1.46.0/clientconn.go:998 +0x4b
panic({0x1124f80, 0x1c52bc0})
        runtime/panic.go:838 +0x207
google.golang.org/grpc.(*ClientConn).Invoke(0x80203cf18?, {0x1464490?, 0xc00054ec60?}, {0x1292a76?, 0x0?}, {0x118afc0?, 0xc00054c040?}, {0x118b080?, 0xc00054c180?}, {0x0, ...})
        google.golang.org/grpc@v1.46.0/call.go:32 +0x5e
github.com/juanfont/headscale/gen/go/headscale/v1.(*headscaleServiceClient).ListMachines(0xc00007a780, {0x1464490, 0xc00054ec60}, 0xc0002f4420?, {0x0, 0x0, 0x0})
        github.com/juanfont/headscale/gen/go/headscale/v1/headscale_grpc.pb.go:195 +0xce
github.com/juanfont/headscale/cmd/headscale/cli.glob..func16(0x1c666e0?, {0x125c23c?, 0x2?, 0x2?})
        github.com/juanfont/headscale/cmd/headscale/cli/nodes.go:168 +0x2d0
github.com/spf13/cobra.(*Command).execute(0x1c666e0, {0xc000550980, 0x2, 0x2})
        github.com/spf13/cobra@v1.4.0/command.go:860 +0x663
github.com/spf13/cobra.(*Command).ExecuteC(0x1c68260)
        github.com/spf13/cobra@v1.4.0/command.go:974 +0x3b4
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.4.0/command.go:902
github.com/juanfont/headscale/cmd/headscale/cli.Execute()
        github.com/juanfont/headscale/cmd/headscale/cli/root.go:85 +0x25
main.main()
        github.com/juanfont/headscale/cmd/headscale/headscale.go:42 +0x235

To Reproduce

  1. Invoke headscale with --output json against a backend that is not running.

Context info

  • Version of headscale used: v0.16.0-beta4 (and v0.15.0)
  • Version of tailscale client: N/A
  • OS (e.g. Linux, Mac, Cygwin, WSL, etc.) and version: FreeBSD 13.1-RELEASE
Originally created by @rcmcdonald91 on GitHub (Jun 17, 2022). <!-- Headscale is a multinational community across the globe. Our common language is English. Please consider raising the bug report in this language. --> When running `headscale nodes list --output json` against a server that is offline, a segfault is encountered. `headscale nodes list` fails gracefully with `Could not connect....`. This segfault is problematic for frontends that consume json output exclusively. ``` $ headscale nodes list --output json panic: runtime error: invalid memory address or nil pointer dereference panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0xb1feab] goroutine 1 [running]: google.golang.org/grpc.(*ClientConn).Close(0x0) google.golang.org/grpc@v1.46.0/clientconn.go:998 +0x4b panic({0x1124f80, 0x1c52bc0}) runtime/panic.go:838 +0x207 google.golang.org/grpc.(*ClientConn).Invoke(0x80203cf18?, {0x1464490?, 0xc00054ec60?}, {0x1292a76?, 0x0?}, {0x118afc0?, 0xc00054c040?}, {0x118b080?, 0xc00054c180?}, {0x0, ...}) google.golang.org/grpc@v1.46.0/call.go:32 +0x5e github.com/juanfont/headscale/gen/go/headscale/v1.(*headscaleServiceClient).ListMachines(0xc00007a780, {0x1464490, 0xc00054ec60}, 0xc0002f4420?, {0x0, 0x0, 0x0}) github.com/juanfont/headscale/gen/go/headscale/v1/headscale_grpc.pb.go:195 +0xce github.com/juanfont/headscale/cmd/headscale/cli.glob..func16(0x1c666e0?, {0x125c23c?, 0x2?, 0x2?}) github.com/juanfont/headscale/cmd/headscale/cli/nodes.go:168 +0x2d0 github.com/spf13/cobra.(*Command).execute(0x1c666e0, {0xc000550980, 0x2, 0x2}) github.com/spf13/cobra@v1.4.0/command.go:860 +0x663 github.com/spf13/cobra.(*Command).ExecuteC(0x1c68260) github.com/spf13/cobra@v1.4.0/command.go:974 +0x3b4 github.com/spf13/cobra.(*Command).Execute(...) github.com/spf13/cobra@v1.4.0/command.go:902 github.com/juanfont/headscale/cmd/headscale/cli.Execute() github.com/juanfont/headscale/cmd/headscale/cli/root.go:85 +0x25 main.main() github.com/juanfont/headscale/cmd/headscale/headscale.go:42 +0x235 ``` <!-- A clear and concise description of what the bug is. Describe the expected bahavior and how it is currently different. If you are unsure if it is a bug, consider discussing it on our Discord server first. --> **To Reproduce** 1. Invoke `headscale` with `--output json` against a backend that is not running. **Context info** - Version of headscale used: v0.16.0-beta4 (and v0.15.0) - Version of tailscale client: N/A - OS (e.g. Linux, Mac, Cygwin, WSL, etc.) and version: FreeBSD 13.1-RELEASE
adam added the bug label 2025-12-29 01:25:51 +01:00
adam closed this issue 2025-12-29 01:25:51 +01:00
Author
Owner

@luckman212 commented on GitHub (Jun 22, 2022):

@theonemcdonald Does this mean headscale is coming someday to pfSense? 👀

@luckman212 commented on GitHub (Jun 22, 2022): @theonemcdonald Does this mean headscale is coming someday to pfSense? 👀
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#277