8000 fix(gateway): guard nil SessionID when logging EventResumed by Saiop68 · Pull Request #633 · disgoorg/disgo · GitHub
[go: up one dir, main page]

Skip to content

fix(gateway): guard nil SessionID when logging EventResumed - #633

Closed
Saiop68 wants to merge 1 commit into
disgoorg:masterfrom
Saiop68:fix/gateway-nil-session-resumed
Closed

Saiop68 wants to merge 1 commit into
disgoorg:masterfrom
Saiop68:fix/gateway-nil-session-resumed

Conversation

@Saiop68
@Saiop68 Saiop68 commented Oct 23, 2026
Copy link
Copy Markdown
Contributor

Overview

This PR fixes a nil pointer dereference in gateway.listen when handling EventResumed after a connection reset or invalid session, as reported in #631.

Root Cause

When a gateway connection receives OpcodeInvalidSession with canResume == false or experiences a reconnect sequence, g.config.SessionID is cleared to nil. If an EventResumed event is subsequently processed, gateway.go:658 unconditionally dereferences *g.config.SessionID for the debug log:

g.config.Logger.Debug("successfully resumed", slog.String("session_id", *g.config.SessionID))

This triggers a fatal SIGSEGV panic (addr=0x0).

Changes

  1. gateway/gateway.go (EventResumed): Guard g.config.SessionID with a nil check before logging session_id.
  2. gateway/gateway.go (resume): Add a defensive guard check in resume() so it returns an error instead of panicking if called without a session ID or sequence number.

Closes #631

@topi314
topi314 commented Oct 23, 2026
Copy link
Copy Markdown
Member

probably replaced by #634

@topi314 topi314 closed this Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

panic: runtime error: invalid memory address or nil pointer dereference in gateway.listen on EventResumed (gateway.go:658)

2 participants

0