[GH-ISSUE #79] nil pointer dereference in cmd/daemon/controls.go:42 #58

Closed
opened 2026-02-28 14:25:01 +03:00 by kerem · 1 comment
Owner

Originally created by @ius on GitHub (Sep 4, 2024).
Original GitHub issue: https://github.com/devgianlu/go-librespot/issues/79

Not entirely sure how I triggered it, but there's a nil pointer dereference path in:

github.com/devgianlu/go-librespot@b98dad6c89/cmd/daemon/controls.go (L40-L42)

INFO[0007] loaded track "All It Takes" (paused: false, position: 399105ms, duration: 328800ms, prefetched: false)  uri="spotify:track:1H8RteGZrEFg5zuvy9Kljz"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x94216e]

goroutine 124 [running]:
main.(*AppPlayer).prefetchNext(0xc000160780)
        /home/user/git/go-librespot/cmd/daemon/controls.go:42 +0x60e
created by main.(*AppPlayer).schedulePrefetchNext in goroutine 1
        /home/user/git/go-librespot/cmd/daemon/controls.go:56 +0x18c

I suppose p.secondaryStream.Media is nil here?

Originally created by @ius on GitHub (Sep 4, 2024). Original GitHub issue: https://github.com/devgianlu/go-librespot/issues/79 Not entirely sure how I triggered it, but there's a nil pointer dereference path in: https://github.com/devgianlu/go-librespot/blob/b98dad6c894b94ee71d30d7ed54f2955ee7f53c4/cmd/daemon/controls.go#L40-L42 ``` INFO[0007] loaded track "All It Takes" (paused: false, position: 399105ms, duration: 328800ms, prefetched: false) uri="spotify:track:1H8RteGZrEFg5zuvy9Kljz" panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x94216e] goroutine 124 [running]: main.(*AppPlayer).prefetchNext(0xc000160780) /home/user/git/go-librespot/cmd/daemon/controls.go:42 +0x60e created by main.(*AppPlayer).schedulePrefetchNext in goroutine 1 /home/user/git/go-librespot/cmd/daemon/controls.go:56 +0x18c ``` I suppose `p.secondaryStream.Media` is nil here?
kerem 2026-02-28 14:25:01 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@devgianlu commented on GitHub (Sep 5, 2024):

Media is only written upon initialization of the object and is surely non-nil at that time. I think secondaryStream became nil because prefetchNext runs in a goroutine and shouldn't access that stuff directly as the goroutine that handles command may be changing stuff (for example in loadCurrentTrack).

It is not trivial to fix, but hopefully shouldn't happen very often.

<!-- gh-comment-id:2330841552 --> @devgianlu commented on GitHub (Sep 5, 2024): `Media` is only written upon initialization of the object and is surely non-nil at that time. I think `secondaryStream` became nil because `prefetchNext` runs in a goroutine and shouldn't access that stuff directly as the goroutine that handles command may be changing stuff (for example in `loadCurrentTrack`). It is not trivial to fix, but hopefully shouldn't happen very often.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/go-librespot#58
No description provided.