mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 15:43:49 +01:00
fix(guild): fix nil panics causing clan menu softlock (#171)
The crash was in handleMsgMhfGetGuildManageRight where a variable shadowing bug (guild, err := instead of guild, err =) left the outer guild pointer nil after the inner GetByID lookup succeeded, panicking at guild.MemberCount. This is confirmed by the user's stack trace pointing to handlers_guild.go:234. Also fix 6 other nil-dereference risks across guild handlers: - handleMsgMhfArrangeGuildMember: guild nil after GetByID - handleMsgMhfEnumerateGuildMember: alliance nil when AllianceID > 0 - handleMsgMhfUpdateGuildIcon: guild and characterInfo nil - handleMsgMhfOperateGuild: guild nil, characterGuildInfo nil - handleAvoidLeadershipUpdate: characterGuildData nil Improve panic recovery to log opcode and full stack trace so future panics can be diagnosed from console screenshots.
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"runtime/debug"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
@@ -240,7 +241,12 @@ func (s *Session) handlePacketGroup(pktGroup []byte) {
|
||||
// This shouldn't be needed, but it's better to recover and let the connection die than to panic the server.
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
s.logger.Error("Recovered from panic", zap.String("name", s.Name), zap.Any("panic", r))
|
||||
s.logger.Error("Recovered from panic",
|
||||
zap.String("name", s.Name),
|
||||
zap.Stringer("opcode", opcode),
|
||||
zap.Any("panic", r),
|
||||
zap.String("stack", string(debug.Stack())),
|
||||
)
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user