Segmentation Fault on OpenBSD 7.5 #685

Closed
opened 2025-12-29 02:22:03 +01:00 by adam · 7 comments
Owner

Originally created by @Charadon on GitHub (Apr 5, 2024).

Bug description

Headscale fails to run with the following error:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x16ad5e8]

goroutine 1 [running]:
modernc.org/libc.(*TLS).setErrno(0x1c59020?, {0x292f80?, 0x656220?})
        modernc.org/libc@v1.22.2/etc.go:189 +0xa8
modernc.org/libc.Xmalloc(0x0, 0x334ec0?)
        modernc.org/libc@v1.22.2/mem.go:34 +0xc5
modernc.org/libc.init()
        modernc.org/libc@v1.22.2/libc_openbsd.go:49 +0x2a9

I've tried using the port and building from source, both give the same error.

Environment

  • Version of headscale used: 0.22.1
  • Version of tailscale client: N/A
  • OS: OpenBSD
  • Kernel version: 7.5
  • Log output: See above

  • Headscale is behind a (reverse) proxy
  • Headscale runs in a container

To Reproduce

Install OpenBSD 7.5
pkg_add headscale or build from source
Run headscale

Logs and attachments

No logs as it segfaults immediately

This is most likely related: https://gitlab.com/cznic/libc/-/issues/34

Originally created by @Charadon on GitHub (Apr 5, 2024). <!-- Before posting a bug report, discuss the behaviour you are expecting with the Discord community to make sure that it is truly a bug. The issue tracker is not the place to ask for support or how to set up Headscale. Bug reports without the sufficient information will be closed. Headscale is a multinational community across the globe. Our language is English. All bug reports needs to be in English. --> ## Bug description Headscale fails to run with the following error: ``` panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x16ad5e8] goroutine 1 [running]: modernc.org/libc.(*TLS).setErrno(0x1c59020?, {0x292f80?, 0x656220?}) modernc.org/libc@v1.22.2/etc.go:189 +0xa8 modernc.org/libc.Xmalloc(0x0, 0x334ec0?) modernc.org/libc@v1.22.2/mem.go:34 +0xc5 modernc.org/libc.init() modernc.org/libc@v1.22.2/libc_openbsd.go:49 +0x2a9 ``` I've tried using the port and building from source, both give the same error. ## Environment - Version of headscale used: 0.22.1 - Version of tailscale client: N/A - OS: OpenBSD - Kernel version: 7.5 - Log output: See above --- <!-- We do not support running Headscale in a container nor behind a (reverse) proxy. If either of these are true for your environment, ask the community in Discord instead of filing a bug report. --> - [ ] Headscale is behind a (reverse) proxy - [ ] Headscale runs in a container ## To Reproduce Install OpenBSD 7.5 pkg_add headscale or build from source Run `headscale` ## Logs and attachments No logs as it segfaults immediately This is most likely related: https://gitlab.com/cznic/libc/-/issues/34
adam added the bug label 2025-12-29 02:22:03 +01:00
adam closed this issue 2025-12-29 02:22:03 +01:00
Author
Owner

@afh commented on GitHub (Apr 9, 2024):

Happy to report that updating the dependencies—especially libc to version 1.49.3— and then cross compiling for OpenBSD fixes the reported segfault.

go get modernc.org/libc@v1.49.3
go get -u
go mod tidy
/usr/bin/env GOOS=openbsd GOARCH=amd64 go build \
-ldflags="-s -w -X github.com/juanfont/headscale/cmd/headscale/cli.Version=0.22.3" \
github.com/juanfont/headscale/cmd/headscale
@afh commented on GitHub (Apr 9, 2024): Happy to report that updating the dependencies—especially `libc` to [version 1.49.3](https://gitlab.com/cznic/libc/-/tags/v1.49.3)— and then cross compiling for OpenBSD fixes the reported segfault. ```sh go get modernc.org/libc@v1.49.3 go get -u go mod tidy /usr/bin/env GOOS=openbsd GOARCH=amd64 go build \ -ldflags="-s -w -X github.com/juanfont/headscale/cmd/headscale/cli.Version=0.22.3" \ github.com/juanfont/headscale/cmd/headscale ```
Author
Owner

@skarekrow commented on GitHub (Apr 9, 2024):

Unfortunately I see a Failed to get headscale configuration error="netip.ParsePrefix(\"\"): no '/'" when running it now. But it does not segfault anymore.

EDIT: Seems to be the example config perhaps shipped with OpenBSD. I grabbed this and that works just fine with edits made to the paths.

EDIT2: For those coming after, the ip4 prefixes and the database type need to be changed in the OpenBSD shipped config, as it was for 0.22.3

They should be:

prefixes:
  v6: fd7a:115c:a1e0::/48
  v4: 100.64.0.0/10
database:
  type: sqlite3

Not

ip_prefixes:
  - fd7a:115c:a1e0::/48
  - 100.64.0.0/10
db_type: sqlite3
@skarekrow commented on GitHub (Apr 9, 2024): Unfortunately I see a `Failed to get headscale configuration error="netip.ParsePrefix(\"\"): no '/'"` when running it now. But it does not segfault anymore. EDIT: Seems to be the example config perhaps shipped with OpenBSD. I grabbed [this](https://raw.githubusercontent.com/juanfont/headscale/main/config-example.yaml) and that works just fine with edits made to the paths. EDIT2: For those coming after, the ip4 prefixes and the database type need to be changed in the OpenBSD shipped config, as it was for 0.22.3 They should be: ``` prefixes: v6: fd7a:115c:a1e0::/48 v4: 100.64.0.0/10 database: type: sqlite3 ``` Not ``` ip_prefixes: - fd7a:115c:a1e0::/48 - 100.64.0.0/10 db_type: sqlite3 ```
Author
Owner

@afh commented on GitHub (Apr 9, 2024):

This seems to be a somewhat recent and breaking change (see CHANGELOG.md) for 0.23.0 from 384ca03208. I shall make a mental note of it for when I update headscale to 0.23.x.

@afh commented on GitHub (Apr 9, 2024): This seems to be a somewhat recent and breaking change (see [`CHANGELOG.md`](https://github.com/juanfont/headscale/blob/main/CHANGELOG.md#breaking)) for 0.23.0 from 384ca032083a4f51f966b86911f01abc88aa8f5c. I shall make a mental note of it for when I update headscale to 0.23.x.
Author
Owner

@lcheylus commented on GitHub (Apr 9, 2024):

@skarekrow I'm the maintainer for the OpenBSD port of headscale. The config file shipped in port is for 0.22.3 version (latest official release).

It seems that you are trying to compile the current headscale version (future version 0.23.0) and as said by @afh, the format of the configuration has changed.

@lcheylus commented on GitHub (Apr 9, 2024): @skarekrow I'm the maintainer for the OpenBSD port of headscale. The config file shipped in port is for 0.22.3 version (latest official release). It seems that you are trying to compile the current headscale version (future version 0.23.0) and as said by @afh, the format of the configuration has changed.
Author
Owner

@skarekrow commented on GitHub (Apr 9, 2024):

@skarekrow I'm the maintainer for the OpenBSD port of headscale. The config file shipped in port is for 0.22.3 version (latest official release).

It seems that you are trying to compile the current headscale version (future version 0.23.0) and as said by @afh, the format of the configuration has changed.

Yep that was the problem. I didn't look close enough to see that it went from .22 -> .23, so it had nothing to do with the package! I appreciate the effort in packaging it, and I'm really glad to see you around here and aware of this issue too.

@skarekrow commented on GitHub (Apr 9, 2024): > @skarekrow I'm the maintainer for the OpenBSD port of headscale. The config file shipped in port is for 0.22.3 version (latest official release). > > It seems that you are trying to compile the current headscale version (future version 0.23.0) and as said by @afh, the format of the configuration has changed. Yep that was the problem. I didn't look close enough to see that it went from .22 -> .23, so it had nothing to do with the package! I appreciate the effort in packaging it, and I'm really glad to see you around here and aware of this issue too.
Author
Owner

@Charadon commented on GitHub (Apr 10, 2024):

Well, if updating the dependencies fixes the issue, then I guess that means a pull request should be opened to do that, right? I'd do it myself, but I have 0 experience with golang lol

@Charadon commented on GitHub (Apr 10, 2024): Well, if updating the dependencies fixes the issue, then I guess that means a pull request should be opened to do that, right? I'd do it myself, but I have 0 experience with golang lol
Author
Owner

@skarekrow commented on GitHub (Apr 10, 2024):

@Charadon I submitted it since there's discussion in this issue and it resolves it for 2 of us. Myself and @afh. Hopefully it gets merged as a point release for 0.22

@skarekrow commented on GitHub (Apr 10, 2024): @Charadon I submitted it since there's discussion in this issue and it resolves it for 2 of us. Myself and @afh. Hopefully it gets merged as a point release for 0.22
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#685