disgoorg / disgo

A modular Golang Discord API Wrapper
Apache License 2.0
328 stars 37 forks source link

gatewayHandlerMessageReactionAdd event panic #330

Closed Agoni-wyt closed 6 months ago

Agoni-wyt commented 8 months ago

I don't know what causes this,It panics my program I need help how should I solve this problem It is recorded in the log that there was no user reaction message before this panic.

Error

 service_stdout: panic: runtime error: invalid memory address or nil pointer dereference

[github.com/disgoorg/disgo/handlers.gatewayHandlerMessageReactionAdd](http://github.com/disgoorg/disgo/handlers.gatewayHandlerMessageReactionAdd)({0x1080270?, 0xc000456320}, 0x122, 0x0, {0xd812f2985c20000, 0xbf3fd9b5812001f, 0xef4943f5e843014, 0xc000d2bd70, 0x0, {0x0, ...}, ...})
/var/lib/jenkins/go/pkg/mod/[github.com/disgoorg/disgo@v0.17.0/handlers/message_reaction_handler.go:51](http://github.com/disgoorg/disgo@v0.17.0/handlers/message_reaction_handler.go:51) +0x33f
[github.com/disgoorg/disgo/bot](http://github.com/disgoorg/disgo/bot).(*genericGatewayEventHandler[...]).HandleGatewayEvent(0xc0003ad7a8?, {0x1080270?, 0xc000456320?}, 0xc0001459b8?, 0xc0003ad728?, {0x106e648?, 0xc0004609a0?})
/var/lib/jenkins/go/pkg/mod/[github.com/disgoorg/disgo@v0.17.0/bot/event_manager.go:111](http://github.com/disgoorg/disgo@v0.17.0/bot/event_manager.go:111) +0x105
[github.com/disgoorg/disgo/bot.(*eventManagerImpl).HandleGatewayEvent](http://github.com/disgoorg/disgo/bot.(*eventManagerImpl).HandleGatewayEvent)(0xc00022fc80, {0xc000bd05e8, 0x14}, 0x4120a5?, 0x100?, {0x106e648, 0xc0004609a0})
/var/lib/jenkins/go/pkg/mod/[github.com/disgoorg/disgo@v0.17.0/bot/event_manager.go:136](http://github.com/disgoorg/disgo@v0.17.0/bot/event_manager.go:136) +0x114
[github.com/disgoorg/disgo/gateway.(*gatewayImpl).listen](http://github.com/disgoorg/disgo/gateway.(*gatewayImpl).listen)(0xc0001d6000, 0xc000248160)
/var/lib/jenkins/go/pkg/mod/[github.com/disgoorg/disgo@v0.17.0/gateway/gateway_impl.go:421](http://github.com/disgoorg/disgo@v0.17.0/gateway/gateway_impl.go:421) +0x70c
created by [github.com/disgoorg/disgo/gateway.(*gatewayImpl).open](http://github.com/disgoorg/disgo/gateway.(*gatewayImpl).open) in goroutine 1
/var/lib/jenkins/go/pkg/mod/[github.com/disgoorg/disgo@v0.17.0/gateway/gateway_impl.go:125](http://github.com/disgoorg/disgo@v0.17.0/gateway/gateway_impl.go:125) +0x37a
topi314 commented 8 months ago

seems like discord sent us a Message Reaction Add event for a guild with a null member, which should not happen. (https://discord.com/developers/docs/topics/gateway-events#message-reaction-add-message-reaction-add-event-fields) does this always occur or was this a once thing?

Agoni-wyt commented 8 months ago

seems like discord sent us a Message Reaction Add event for a guild with a null member, which should not happen. (https://discord.com/developers/docs/topics/gateway-events#message-reaction-add-message-reaction-add-event-fields) does this always occur or was this a once thing?

It will probably appear after a while, but the problem occurred again today.

Agoni-wyt commented 8 months ago

Is it possible that someone who has not joined the community triggered the Message Reaction Add event in the community. Because the relevant fields (guild_id, number) in the document are marked with ? image

JahsehJ commented 8 months ago

Someone probably reacted to a DM message sent by your bot.

topi314 commented 8 months ago

the message_author_id is the id of who sent the message so this field has nothing to do with this.

The guild_id indicates in which guild the event happened, so if its null the event happened in DMs.

Does lurking still exist? I thought they got rid of that

Agoni-wyt commented 6 months ago

Please help me, similar problem occurs again

[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xb6087f]
goroutine 36 [running]:
[github.com/disgoorg/disgo/handlers.gatewayHandlerMessageReactionAdd](http://github.com/disgoorg/disgo/handlers.gatewayHandlerMessageReactionAdd)({0x1080290?, 0xc0001d2dc0}, 0x13b, 0x0, {0x10eb31b152c4101e, 0xdd57905b4843000, 0xdd78506ab04206e, 0xc00055c278, 0x0, {0xc00055c270, ...}, ...})
/var/lib/jenkins/go/pkg/mod/[github.com/disgoorg/disgo@v0.17.0/handlers/message_reaction_handler.go:51](http://github.com/disgoorg/disgo@v0.17.0/handlers/message_reaction_handler.go:51) +0x33f
[github.com/disgoorg/disgo/bot](http://github.com/disgoorg/disgo/bot).(*genericGatewayEventHandler[...]).HandleGatewayEvent(0xc0003b77a8?, {0x1080290?, 0xc0001d2dc0?}, 0xc000187db8?, 0xc0003b7728?, {0x106e668?, 0xc0001de310?})
/var/lib/jenkins/go/pkg/mod/[github.com/disgoorg/disgo@v0.17.0/bot/event_manager.go:111](http://github.com/disgoorg/disgo@v0.17.0/bot/event_manager.go:111) +0x105
[github.com/disgoorg/disgo/bot.(*eventManagerImpl).HandleGatewayEvent](http://github.com/disgoorg/disgo/bot.(*eventManagerImpl).HandleGatewayEvent)(0xc00038c1e0, {0xc001292d50, 0x14}, 0x4120a5?, 0x100?, {0x106e668, 0xc0001de310})
/var/lib/jenkins/go/pkg/mod/[github.com/disgoorg/disgo@v0.17.0/bot/event_manager.go:136](http://github.com/disgoorg/disgo@v0.17.0/bot/event_manager.go:136) +0x114
[github.com/disgoorg/disgo/gateway.(*gatewayImpl).listen](http://github.com/disgoorg/disgo/gateway.(*gatewayImpl).listen)(0xc0005a4dc0, 0xc0003906e0)
/var/lib/jenkins/go/pkg/mod/[github.com/disgoorg/disgo@v0.17.0/gateway/gateway_impl.go:421](http://github.com/disgoorg/disgo@v0.17.0/gateway/gateway_impl.go:421) +0x70c
created by [github.com/disgoorg/disgo/gateway.(*gatewayImpl).open](http://github.com/disgoorg/disgo/gateway.(*gatewayImpl).open) in goroutine 1
/var/lib/jenkins/go/pkg/mod/[github.com/disgoorg/disgo@v0.17.0/gateway/gateway_impl.go:125](http://github.com/disgoorg/disgo@v0.17.0/gateway/gateway_impl.go:125) +0x37a```

During local testing, I found that DM messages would not cause this panic. I have updated disgo to the latest version, but this problem still exists. I don't know what caused the panic.

topi314 commented 6 months ago

this is interesting, the id should be there in case of guild messages Are you able to specifically identify the messages which caused this issue?

I'll drop a fix for this later regardless

Agoni-wyt commented 6 months ago

Because my bot has now joined more than 100 communities, and this problem has never occurred when I tested it locally. Maybe some of the large communities can support people who have not joined to send reactions?

image According to the hexadecimal correspondence in the log, the following ids may look like this:(Convert hexadecimal to decimal) UserID: 931259633646417919 ChannelID: 166396589273924098 MessageID: 12306226622406164 GuildID: 128153451784(a pointer, I don’t know the specific value)

topi314 commented 6 months ago

I pushed a fix for this to master this will be in the next release which but since there are a few breaking changes on master regarding the interaction handler package this might take a few days to get in a release

sebm253 commented 6 months ago

fixed in https://github.com/disgoorg/disgo/releases/tag/v0.18.0