Repository navigation
Closed
Labels
Description
Description
While running the beszel agent on Darwin, after about an hour I'm observing crashes with a stack trace like this:
<snip>
2025/05/04 02:11:59 DEBUG Docker stats err="Get \"http://localhost/containers/json\": dial unix /var/run/docker.sock: connect: no such file or directory"
2025/05/04 02:11:59 DEBUG Extra filesystems data=map[]
2025/05/04 02:12:59 DEBUG New session client=192.168.1.30:48500
2025/05/04 02:12:59 DEBUG Cached stats session=6f20e5726c873ff1ba88e0196828406e94880ddc1fd3d6eae64e3c35974f6049
2025/05/04 02:13:59 DEBUG New session client=192.168.1.30:48576
unexpected fault address 0x104c0b000
fatal error: fault
[signal SIGBUS: bus error code=0x1 addr=0x104c0b000 pc=0x104c0b008]
goroutine 1850 gp=0x14000846e00 m=10 mp=0x14000282008 [running]:
runtime.throw({0x104e040f9?, 0x0?})
/home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.24.2.linux-amd64/src/runtime/panic.go:1101 +0x38 fp=0x140007f2ff0 sp=0x140007f2fc0 pc=0x104b49d68
runtime.sigpanic()
/home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.24.2.linux-amd64/src/runtime/signal_unix.go:922 +0x170 fp=0x140007f3050 sp=0x140007f2ff0 pc=0x104b4bdb0
github.com/shirou/gopsutil/v4/internal/common.NewLibrary({0x10000000000, 0x1000000d2})
/home/runner/go/pkg/mod/github.com/shirou/gopsutil/v4@v4.25.3/internal/common/common_darwin.go:91 +0x48 fp=0x140007f30a0 sp=0x140007f3060 pc=0x104c0b008
github.com/shirou/gopsutil/v4/sensors.TemperaturesWithContext({0x104b529c0?, 0x140007f3588?})
/home/runner/go/pkg/mod/github.com/shirou/gopsutil/v4@v4.25.3/sensors/sensors_darwin_arm64.go:54 +0x6c4 fp=0x140007f3540 sp=0x140007f30a0 pc=0x104d4f764
created by github.com/gliderlabs/ssh.(*session).handleRequests in goroutine 1849
/home/runner/go/pkg/mod/github.com/gliderlabs/ssh@v0.3.8/session.go:260 +0x504
And there are a thousand more goroutine stacks listed, many of them mentioning ssh.
Using homebrew as the install method.
Expected Behavior
No crash
Steps to Reproduce
- Invoke agent like so:
LOG_LEVEL=debug KEY="ssh-ed25519 ..." /opt/homebrew/Cellar/beszel-agent/0.11.1/bin/beszel-agen - Wait for crash, in this case about 3h 45m later.
OS / Architecture
Darwin/macOS 15.4.1
Beszel version
0.11.1
Installation method
Binary
Configuration
Hub Logs
Agent Logs
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Activity
henrygd commentedon May 4, 2025
Thanks for the report, I think this might be related to the sensors package. There have been a few different issues with that on darwin.
Please try adding
SENSORS=""to~/.config/beszel/beszel-agent.envand restart the agent withbrew services restart beszel-agent.Let me know if you get the same error, otherwise please let it run for a day or so. I just want to narrow down possible causes before looking further into it.
henrygd commentedon May 4, 2025
Check that - spent a bit more time looking into it. I think it may be related to this purego issue: ebitengine/purego#309
Not 100% sure on that, but a fix has been merged on their end for 0.9.0, so we'll upgrade when that's released.
If you want to try yourself you will need to compile the agent.
Before running
make build-agent, rungo get github.com/ebitengine/purego@v0.9.0-alpha.3to upgrade to their latest alpha release.You can change the binary location for the brew service by editing the last line in
/usr/local/bin/beszel-agent-launcherto point to your compiled binary, then restart the service withbrew services restart beszel-agent.I'm not asking you do to this, to be clear. Just providing the option if you want to try it.
Edit: This is still likely related to the sensors package, so
SENSORS=""may keep it running for the time being.mmisiewicz commentedon May 6, 2025
Upgrading the
puregopackage (by runninggo get github.com/ebitengine/purego@v0.9.0-alpha.3before runningmake build-agentand then invoking the compiled binary directly with KEY and DEBUG) did not help the problem. Same crash. The last goroutine in the stack is suggestive of the sensors theory:mmisiewicz commentedon May 6, 2025
SENSORS=""seems to have caused the crashing to stop. Though of course there's no sensor data now.dlhall111 commentedon May 7, 2025
@henrygd just to give you an additional data point: I'd been having these same crashes with my MacOS agent instance as well, usually 2-3 per day. I set SENSORS="" late yesterday and haven't had a crash so far, which is probably the longest uptime I've had with the agent on MacOS. :)
Awesome project BTW!!
henrygd commentedon May 7, 2025
Thanks, the additional stack trace is helpful. I'll fork gopsutil and see if I can figure out a fix.
I run macOS in a VM with no access to sensors, I will need others to test.
mmisiewicz commentedon May 7, 2025
I can send along a full stack trace if that helps, though there are ~4000 stacks in the full trace.
henrygd commentedon May 9, 2025
Here's a binary to test.
If you want to build yourself, swap
github.com/shirou/gopsutil/v4forgithub.com/henrygd/gopsutil/v4. Make sure the latter is onv4.25.6.https://static.beszel.dev/issues/796/beszel-agent_darwin_arm64
mmisiewicz commentedon May 9, 2025
this binary crashed for me:
luckman212 commentedon May 9, 2025
Linking #531 for reference, adding
SENSORS=""to~/.config/beszel/beszel-agent.envalso stopped my crashes. So, definitely something there.henrygd commentedon May 9, 2025
Thanks, here's a new binary for testing:
https://beszel.b-cdn.net/issues/796/v2/beszel-agent_darwin_arm64
If you want to build yourself, please see if specifying
CGO_ENABLED=0orCGO_ENABLED=1makes any difference:luckman212 commentedon May 10, 2025
I've got this new agent installed on a test system, and removed the
SENSORS=""for now. Will report back.luckman212 commentedon May 10, 2025
Started producing bad JSON after ~2 hrs.
Log and copy of the invalid JSON attached. I reverted to the previous build and put
SENSORS=""back for now.luckman212 commentedon May 14, 2025
@henrygd Does it help if I have a spare old Mac laptop I can ship to you so you have hardware to test with?
12 remaining items
check for malformed sensor names on darwin (#796)
luckman212 commentedon Jul 25, 2025
I saw 3586f73 but wasn't quite sure - does that mean we no longer need
SENSORS=""?henrygd commentedon Jul 25, 2025
I'm not sure either since I don't have an affected system. Most likely it will not fix it, but I figured it was worth a try.
Here's the upstream issue if anyone wants to investigate further: shirou/gopsutil#1832
luckman212 commentedon Jul 27, 2025
After a short while, the agent started producing the invalid JSON again. This is as of 0.12.1. So for now I've reverted to adding
SENSORS=""back into my env file. I know this is an upstream issue @henrygd - just noting.[-][Bug]: Mac agent crashes with SIGBUS in sensors_darwin_arm64[/-][+][Bug] Mac agent crashes or sends malformed data[/+]fix(agent): upgrade gopsutil to v4.26.3 to resolve macOS ARM64 crashes (
henrygd commentedon Apr 2, 2026
This is likely fixed in the next version, which should be out today or tomorrow. If it's still not working, let me know and I'll reopen the issue.
Reference: #1881
fix(agent): upgrade gopsutil to v4.26.3 to resolve macOS ARM64 crashes (