disgord: SIGSEGV panic when a voice reconnect is triggered

Describe the bug I have written a bot to listen for a single command, connect to a voice channel, ‘speak’ into it, then leave. This is identical code to this repo’s Connecting to Voice example (only this time with real error handling. Everything works fine in a local environment

The bug: When running this in a Docker container on a Digital Ocean droplet, there is a runtime error every single time without fail. I receive this exact error a few times during local development too, but very infrequently. In the production environment, it crashes everytime.

Expected behavior I expect to listen for a command, and send the single .dca audio through to a voice channel. Simple, just like the Connecting to Voice example.

Error messages

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

goroutine 40 [running]:
github.com/andersfylling/disgord.(*voiceRepository).VoiceConnectOptions(0xc00000ca00, 0x7c3a16e2a840002, 0x7c3a16e58c20003, 0x0, 0x0, 0x0, 0x0, 0x0)
	/go/pkg/mod/github.com/andersfylling/disgord@v0.17.1/voiceconnection.go:187 +0x731
github.com/andersfylling/disgord.(*voiceRepository).VoiceConnect(0xc00000ca00, 0x7c3a16e2a840002, 0x7c3a16e58c20003, 0x0, 0x0, 0x0, 0x0)
	/go/pkg/mod/github.com/andersfylling/disgord@v0.17.1/voiceconnection.go:86 +0x46
main.(*ZahtBot).zaht(0xc00000ca20, 0x9ca660, 0xc0000d2000, 0xc00014b740)
	/ZahtBot/cmd/bot/zahtbot.go:63 +0xbc
main.(*ZahtBot).mux(...)
	/ZahtBot/cmd/bot/zahtbot.go:56
github.com/andersfylling/disgord.(*dispatcher).trigger(0xc00007c7c0, 0x86d7c0, 0xc00004b510, 0x8b7d60, 0xc00014b740)
	/go/pkg/mod/github.com/andersfylling/disgord@v0.17.1/reactor_gen.go:467 +0x4d8
github.com/andersfylling/disgord.(*dispatcher).dispatch(0xc00007c7c0, 0x9bd2c0, 0xc000022030, 0xc0001d2180, 0xe, 0x8b7d60, 0xc00014b740)
	/go/pkg/mod/github.com/andersfylling/disgord@v0.17.1/reactor.go:154 +0x31f
created by github.com/andersfylling/disgord.demultiplexer
	/go/pkg/mod/github.com/andersfylling/disgord@v0.17.1/reactor.go:76 +0x274

Desktop (please complete the following information):

  • Golang version: v1.14.3
  • Using Go modules? yes
  • Disgord version? v0.17.1
  • Connected to the gateway before using REST methods? N/A (I don’t believe I’m using any REST methods… correct me if I’m wrong)

Additional context Here is the relevant code. This should be identical to this repo’s Connecting to Voice example, only this time with error handling.

func (zb *ZahtBot) zaht(session disgord.Session, m *disgord.MessageCreate) {
	log.Println("Zahting...")

        // the line below this comment is where my code is crashing
	voice, err := session.VoiceConnect(m.Message.GuildID, hardcodedChannelID)
	if err != nil {
		log.Printf("Voice Connect error: %+v\n", err)
		return
	}
	defer voice.Close()

	err = voice.StartSpeaking()
	if err != nil {
		log.Printf("Start Speaking error: %+v\n", err)
		return
	}

	err = voice.SendDCA(bytes.NewReader(zb.dca))
	if err != nil {
		log.Printf("Send DCA error: %+v\n", err)
		return
	}

	err = voice.StopSpeaking()
	if err != nil {
		log.Printf("Stop Speaking error: %+v\n", err)
		return
	}

	log.Println("Zahted!")
}

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (10 by maintainers)

Commits related to this issue

Most upvoted comments

From the logs we do see that it happens on a reconnect. So I’ll restrict this issue to that. Once that is resolved, we can see if there are still any defect behavior in docker.