Skip to content

bug: fix SIGSEGV during shutdown with --nocache (low-priority)#531

Merged
nuttycom merged 1 commit intozcash:masterfrom
LarryRuane:2025-08-nocache-shutdown-segfault
Feb 19, 2026
Merged

bug: fix SIGSEGV during shutdown with --nocache (low-priority)#531
nuttycom merged 1 commit intozcash:masterfrom
LarryRuane:2025-08-nocache-shutdown-segfault

Conversation

@LarryRuane
Copy link
Collaborator

Low-priority bugfix, follow-on to #483 - prevent segmentation fault when lightwalletd exits (for example, receives a control-C):

{"app":"lightwalletd","level":"info","msg":"Starting gRPC server on 127.0.0.1:9067","time":"2025-08-13T14:19:45-06:00"}
^Cpanic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0xa92db3]

goroutine 12 [running]:
github.com/zcash/lightwalletd/common.(*BlockCache).Sync(0x0)
	/sd/g/lightwalletd/common/cache.go:384 +0x13
github.com/zcash/lightwalletd/cmd.startServer.func1()
	/sd/g/lightwalletd/cmd/root.go:305 +0x69
created by github.com/zcash/lightwalletd/cmd.startServer in goroutine 1
	/sd/g/lightwalletd/cmd/root.go:303 +0x1da9
exit status 2

The bug is that if lightwalletd is started with the --nocache configuration, the cache variable isn't set (is nil), but we're not testing it before dereferencing it during shutdown (after receiving a signal).

I verified that this variable, cache, cannot be changing while it's being tested (for nil value), because it's set (or not) earlier in this same function (before the asynchronous goroutine is launched). Although, that would have been a bug previously too.

@LarryRuane LarryRuane requested review from daira, nuttycom and y4ssi August 13, 2025 20:35
@LarryRuane LarryRuane self-assigned this Aug 13, 2025
@LarryRuane LarryRuane added the bug Something isn't working label Aug 13, 2025
Copy link
Contributor

@nuttycom nuttycom left a comment

Choose a reason for hiding this comment

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

utACK; this looks trivially safe.

@nuttycom nuttycom merged commit da2f8c2 into zcash:master Feb 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants