[GH-ISSUE #159] invalid memory address or nil pointer dereference in api_server.go #102

Closed
opened 2026-02-28 14:25:22 +03:00 by kerem · 4 comments
Owner

Originally created by @pilollipietro on GitHub (Jan 12, 2025).
Original GitHub issue: https://github.com/devgianlu/go-librespot/issues/159

With git master code updated at Commit 30c81e8

DEBU[0011] loading track (paused: false, position: 30945ms) uri="spotify:track:4hhNhWxf64zgd6MgONhFfV"
DEBU[0011] put connect state because PLAYER_STATE_CHANGED
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x2c pc=0x5e7e20]

goroutine 1 [running]:
main.(*ApiServer).Emit(0x28d6300, 0x2aaed00)
/src/cmd/daemon/api_server.go:610 +0xd4
main.(*AppPlayer).loadCurrentTrack(0x28a28c0, {0x7d19f4, 0xbeffc8}, 0x0, 0x1)
/src/cmd/daemon/controls.go:221 +0x49c
main.(*AppPlayer).handlePlayerCommand(0x28a28c0, {0x7d19f4, 0xbeffc8}, {0x5b27dadf, {0x2ab0630, 0x28}, {{0x2ac1170, 0x8}, {0x0, 0x0}, ...}})
/src/cmd/daemon/player.go:237 +0x1c8c
main.(*AppPlayer).handleDealerRequest(0x28a28c0, {0x7d19f4, 0xbeffc8}, {0x2889e40, {0x2a97a40, 0x24}, {0x5b27dadf, {0x2ab0630, 0x28}, {{0x2ac1170, ...}, ...}}})
/src/cmd/daemon/player.go:354 +0x11c
main.(*AppPlayer).Run(0x28a28c0, {0x7d19f4, 0xbeffc8}, 0x28881c0)
/src/cmd/daemon/player.go:582 +0x55c
main.(*App).withAppPlayer(0x28ac400, {0x7d19f4, 0xbeffc8}, 0x28a6a30)
/src/cmd/daemon/main.go:227 +0x590
main.(*App).withCredentials(...)
/src/cmd/daemon/main.go:190
main.(*App).Interactive(0x28ac400, {0x7d19f4, 0xbeffc8}, 0x0)
/src/cmd/daemon/main.go:186 +0x98
main.main()
/src/cmd/daemon/main.go:614 +0x714

Originally created by @pilollipietro on GitHub (Jan 12, 2025). Original GitHub issue: https://github.com/devgianlu/go-librespot/issues/159 With git master code updated at Commit 30c81e8 DEBU[0011] loading track (paused: false, position: 30945ms) uri="spotify:track:4hhNhWxf64zgd6MgONhFfV" DEBU[0011] put connect state because PLAYER_STATE_CHANGED panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x2c pc=0x5e7e20] goroutine 1 [running]: main.(*ApiServer).Emit(0x28d6300, 0x2aaed00) /src/cmd/daemon/api_server.go:610 +0xd4 main.(*AppPlayer).loadCurrentTrack(0x28a28c0, {0x7d19f4, 0xbeffc8}, 0x0, 0x1) /src/cmd/daemon/controls.go:221 +0x49c main.(*AppPlayer).handlePlayerCommand(0x28a28c0, {0x7d19f4, 0xbeffc8}, {0x5b27dadf, {0x2ab0630, 0x28}, {{0x2ac1170, 0x8}, {0x0, 0x0}, ...}}) /src/cmd/daemon/player.go:237 +0x1c8c main.(*AppPlayer).handleDealerRequest(0x28a28c0, {0x7d19f4, 0xbeffc8}, {0x2889e40, {0x2a97a40, 0x24}, {0x5b27dadf, {0x2ab0630, 0x28}, {{0x2ac1170, ...}, ...}}}) /src/cmd/daemon/player.go:354 +0x11c main.(*AppPlayer).Run(0x28a28c0, {0x7d19f4, 0xbeffc8}, 0x28881c0) /src/cmd/daemon/player.go:582 +0x55c main.(*App).withAppPlayer(0x28ac400, {0x7d19f4, 0xbeffc8}, 0x28a6a30) /src/cmd/daemon/main.go:227 +0x590 main.(*App).withCredentials(...) /src/cmd/daemon/main.go:190 main.(*App).Interactive(0x28ac400, {0x7d19f4, 0xbeffc8}, 0x0) /src/cmd/daemon/main.go:186 +0x98 main.main() /src/cmd/daemon/main.go:614 +0x714
kerem closed this issue 2026-02-28 14:25:22 +03:00
Author
Owner

@devgianlu commented on GitHub (Jan 12, 2025):

I am a little bit confused, I don't see how this could happen. Did you modify the code in any way?

<!-- gh-comment-id:2585894717 --> @devgianlu commented on GitHub (Jan 12, 2025): I am a little bit confused, I don't see how this could happen. Did you modify the code in any way?
Author
Owner

@wasamasa commented on GitHub (Jan 13, 2025):

I have managed to get a similar crash on HEAD after editing my config to look as follows:

zeroconf_enabled: false
credentials:
  type: interactive

log_level: debug
audio_backend: pulseaudio

server:
  enabled: false # HINT, HINT
  address: localhost
  port: 3678

Then, shortly after launching:

DEBU[0000] received connection id: <REDACTED>
DEBU[0000] put connect state because NEW_DEVICE         
DEBU[0000] update volume to 65535/65535                 
DEBU[0001] put connect state because VOLUME_CHANGED     
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x50 pc=0x61f6006105a5]

goroutine 1 [running]:
main.(*ApiServer).Emit(0xc0002023f0, 0xc000290060)
        github.com/devgianlu/go-librespot/cmd/daemon/api_server.go:610 +0x105
main.(*AppPlayer).volumeUpdated(0xc0000dca00, {0x61f600890a78?, 0x61f600d276a0?})
        github.com/devgianlu/go-librespot/cmd/daemon/controls.go:613 +0x18a
main.(*AppPlayer).Run(0xc0000dca00, {0x61f600890a78, 0x61f600d276a0}, 0xc0000a8380)
        github.com/devgianlu/go-librespot/cmd/daemon/player.go:605 +0x947
main.(*App).withAppPlayer(0xc0002185b0, {0x61f600890a78, 0x61f600d276a0}, 0x61f6007f3fa0?)
        github.com/devgianlu/go-librespot/cmd/daemon/main.go:227 +0x56a
main.(*App).withCredentials(...)
        github.com/devgianlu/go-librespot/cmd/daemon/main.go:190
main.(*App).Interactive(0xc0002185b0, {0x61f600890a78, 0x61f600d276a0}, 0x17?)
        github.com/devgianlu/go-librespot/cmd/daemon/main.go:186 +0x97
main.main()
        github.com/devgianlu/go-librespot/cmd/daemon/main.go:614 +0x5c5
<!-- gh-comment-id:2586029231 --> @wasamasa commented on GitHub (Jan 13, 2025): I have managed to get a similar crash on HEAD after editing my config to look as follows: ```yaml zeroconf_enabled: false credentials: type: interactive log_level: debug audio_backend: pulseaudio server: enabled: false # HINT, HINT address: localhost port: 3678 ``` Then, shortly after launching: ``` DEBU[0000] received connection id: <REDACTED> DEBU[0000] put connect state because NEW_DEVICE DEBU[0000] update volume to 65535/65535 DEBU[0001] put connect state because VOLUME_CHANGED panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x50 pc=0x61f6006105a5] goroutine 1 [running]: main.(*ApiServer).Emit(0xc0002023f0, 0xc000290060) github.com/devgianlu/go-librespot/cmd/daemon/api_server.go:610 +0x105 main.(*AppPlayer).volumeUpdated(0xc0000dca00, {0x61f600890a78?, 0x61f600d276a0?}) github.com/devgianlu/go-librespot/cmd/daemon/controls.go:613 +0x18a main.(*AppPlayer).Run(0xc0000dca00, {0x61f600890a78, 0x61f600d276a0}, 0xc0000a8380) github.com/devgianlu/go-librespot/cmd/daemon/player.go:605 +0x947 main.(*App).withAppPlayer(0xc0002185b0, {0x61f600890a78, 0x61f600d276a0}, 0x61f6007f3fa0?) github.com/devgianlu/go-librespot/cmd/daemon/main.go:227 +0x56a main.(*App).withCredentials(...) github.com/devgianlu/go-librespot/cmd/daemon/main.go:190 main.(*App).Interactive(0xc0002185b0, {0x61f600890a78, 0x61f600d276a0}, 0x17?) github.com/devgianlu/go-librespot/cmd/daemon/main.go:186 +0x97 main.main() github.com/devgianlu/go-librespot/cmd/daemon/main.go:614 +0x5c5 ```
Author
Owner

@devgianlu commented on GitHub (Jan 13, 2025):

@wasamasa Thank you for posting! I had missed that. Now fixed.

<!-- gh-comment-id:2586507096 --> @devgianlu commented on GitHub (Jan 13, 2025): @wasamasa Thank you for posting! I had missed that. Now fixed.
Author
Owner

@pilollipietro commented on GitHub (Jan 13, 2025):

Thank you

<!-- gh-comment-id:2587738852 --> @pilollipietro commented on GitHub (Jan 13, 2025): Thank you
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#102
No description provided.