Skip to content

Panic: nil pointer dereference in Obfuscator.SendHandshake #341

@arabesc

Description

@arabesc

I am encountering frequent panics in mtg during connection processing. The panic is captured by the ants worker pool and points to a nil pointer dereference in the obfuscation layer.

Log Output:

{"level":"debug","logger":"ants","timestamp":1772019375656,"message":"worker exits from panic: runtime error: invalid memory address or nil pointer dereference\ngoroutine 3684 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:26 +0x5e\ngithub.com/panjf2000/ants/v2.(*goWorkerWithFunc).run.func1.1()\n\tgithub.com/panjf2000/ants/v2@v2.11.5/worker_func.go:62 +0xd4\npanic({0xa0f9a0?, 0xffcaa0?})\n\truntime/panic.go:860 +0x13a\ngithub.com/9seconds/mtg/v2/mtglib/internal/obfuscation.Obfuscator.SendHandshake({{0x0?, 0xcb?, 0x30?}}, {0x0, 0x0}, 0xcb)\n\tgithub.com/9seconds/mtg/v2/mtglib/internal/obfuscation/obfuscator.go:64 +0x24c\ngithub.com/9seconds/mtg/v2/mtglib.(*Proxy).doTelegramCall(0x872ade120, 0x8728c7920)\n\tgithub.com/9seconds/mtg/v2/mtglib/proxy.go:256 +0x2cd\ngithub.com/9seconds/mtg/v2/mtglib.(*Proxy).ServeConn(0x872ade120, {0xee4b24c0008, 0x872f0c428})\n\tgithub.com/9seconds/mtg/v2/mtglib/proxy.go:89 +0x2ef\ngithub.com/9seconds/mtg/v2/mtglib.NewProxy.func1({0xaaf560?, 0x872f0c428?})\n\tgithub.com/9seconds/mtg/v2/mtglib/proxy.go:354 +0x88\ngithub.com/panjf2000/ants/v2.(*goWorkerWithFunc).run.func1()\n\tgithub.com/panjf2000/ants/v2@v2.11.5/worker_func.go:73 +0x97\ncreated by github.com/panjf2000/ants/v2.(*goWorkerWithFunc).run in goroutine 32\n\tgithub.com/panjf2000/ants/v2@v2.11.5/worker_func.go:50 +0x65\n\n"}

Stack Trace:

goroutine 3684 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:26 +0x5e
github.com/panjf2000/ants/v2.(*goWorkerWithFunc).run.func1.1()
	github.com/panjf2000/ants/v2@v2.11.5/worker_func.go:62 +0xd4
panic({0xa0f9a0?, 0xffcaa0?})
	runtime/panic.go:860 +0x13a
github.com/9seconds/mtg/v2/mtglib/internal/obfuscation.Obfuscator.SendHandshake({{0x0?, 0xcb?, 0x30?}}, {0x0, 0x0}, 0xcb)
	github.com/9seconds/mtg/v2/mtglib/internal/obfuscation/obfuscator.go:64 +0x24c
github.com/9seconds/mtg/v2/mtglib.(*Proxy).doTelegramCall(0x872ade120, 0x8728c7920)
	github.com/9seconds/mtg/v2/mtglib/proxy.go:256 +0x2cd
github.com/9seconds/mtg/v2/mtglib.(*Proxy).ServeConn(0x872ade120, {0xee4b24c0008, 0x872f0c428})
	github.com/9seconds/mtg/v2/mtglib/proxy.go:89 +0x2ef

Environment:

  • mtg version: 2.1.11
  • OS: FreeBSD 14.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions