Open Humberd opened 7 months ago
Medium
When spamming usage of ectoplasm container item from a hotkey the memory of action position variables gets corrupted.
ectoplasm container
[2024-03-14 22:52:03.845] [info] Actions::useItemEx (before isHotkey) fromPos: ( 65535, 0, 0 ), toPos: ( 2078, 2042, 7 ), item: 4852 [2024-03-14 22:52:03.845] [info] Actions::useItemEx (after isHotkey) fromPos: ( 8237, 25965, 115 ), toPos: ( 29816, 25933, 115 ), item: 4852
Inbetween these logs only the network message is being sent.
OS: Windows WSL
main
13.32.14520
g_logger().info("--------------"); g_logger().info("Actions::useItemEx (before isHotkey) fromPos: {}, toPos: {}, item: {}", fromPos.toString(), toPos.toString(), item->getID()); if (isHotkey) { uint16_t subType = item->getSubType(); showUseHotkeyMessage(player, item, player->getItemTypeCount(item->getID(), subType != item->getItemCount() ? subType : -1)); } g_logger().info("Actions::useItemEx (after isHotkey) fromPos: {}, toPos: {}, item: {}", fromPos.toString(), toPos.toString(), item->getID());
With crosshair
The position variables reflect the actual position
[2024-03-14 23:08:41.178] [info] -------------- [2024-03-14 23:08:41.178] [info] Actions::useItemEx (before isHotkey) fromPos: ( 65535, 0, 0 ), toPos: ( 2046, 2060, 7 ), item: 4852 [2024-03-14 23:08:41.178] [info] Actions::useItemEx (after isHotkey) fromPos: ( 65535, 0, 0 ), toPos: ( 2046, 2060, 7 ), item: 4852 [2024-03-14 23:08:42.183] [info] -------------- [2024-03-14 23:08:42.183] [info] Actions::useItemEx (before isHotkey) fromPos: ( 65535, 0, 0 ), toPos: ( 2046, 2060, 7 ), item: 4852 [2024-03-14 23:08:42.183] [info] Actions::useItemEx (after isHotkey) fromPos: ( 8237, 25965, 115 ), toPos: ( 29816, 25933, 115 ), item: 4852 [2024-03-14 23:08:44.945] [info] -------------- [2024-03-14 23:08:44.945] [info] Actions::useItemEx (before isHotkey) fromPos: ( 65535, 0, 0 ), toPos: ( 2046, 2061, 7 ), item: 4852 [2024-03-14 23:08:44.946] [info] Actions::useItemEx (after isHotkey) fromPos: ( 65535, 0, 0 ), toPos: ( 2046, 2061, 7 ), item: 4852 [2024-03-14 23:08:46.094] [info] -------------- [2024-03-14 23:08:46.094] [info] Actions::useItemEx (before isHotkey) fromPos: ( 65535, 0, 0 ), toPos: ( 2048, 2061, 7 ), item: 4852 [2024-03-14 23:08:46.095] [info] Actions::useItemEx (after isHotkey) fromPos: ( 65535, 0, 0 ), toPos: ( 2048, 2061, 7 ), item: 4852 [2024-03-14 23:08:47.094] [info] -------------- [2024-03-14 23:08:47.094] [info] Actions::useItemEx (before isHotkey) fromPos: ( 65535, 0, 0 ), toPos: ( 2049, 2060, 7 ), item: 4852 [2024-03-14 23:08:47.094] [info] Actions::useItemEx (after isHotkey) fromPos: ( 8237, 25965, 115 ), toPos: ( 29816, 25933, 115 ), item: 4852 [2024-03-14 23:08:48.094] [info] --------------
Just invoking showUseHotkeyMessage() method, which does not use either fromPos or toPos changes their internal state.
showUseHotkeyMessage()
fromPos
toPos
It looks like the problem is not with sending a network message itself. I commented the line responsible for sending a network text message, but the corruption remained the same. https://github.com/opentibiabr/canary/blob/b61cd9d4227220dd46c408a11f55c6217d8ba7eb/src/server/network/protocol/protocolgame.cpp#L4175
However, when I also commented a function call to msg.addString(), which internally does a memcpy, the problem was gone. https://github.com/opentibiabr/canary/blob/b61cd9d4227220dd46c408a11f55c6217d8ba7eb/src/server/network/protocol/protocolgame.cpp#L4174-L4175
msg.addString()
memcpy
https://github.com/opentibiabr/canary/assets/10242142/6196d41f-72a5-4cd5-85e9-53e19cb3b4a2
Using rope or shovel works ok.
Linux
This issue is stale because it has been open 120 days with no activity.
I did some tests and everything seems fine.
Priority
Medium
Area
What happened?
Summary
When spamming usage of
ectoplasm container
item from a hotkey the memory of action position variables gets corrupted.Inbetween these logs only the network message is being sent.
Details
OS: Windows WSL
Preparation:
main
branch.13.32.14520
linkSteps to reproduce:
ectoplasm container
item. Id: 4823With crosshair
Expected result
The position variables reflect the actual position
Actual result
Just invoking
showUseHotkeyMessage()
method, which does not use eitherfromPos
ortoPos
changes their internal state.Investigation
It looks like the problem is not with sending a network message itself. I commented the line responsible for sending a network text message, but the corruption remained the same. https://github.com/opentibiabr/canary/blob/b61cd9d4227220dd46c408a11f55c6217d8ba7eb/src/server/network/protocol/protocolgame.cpp#L4175
However, when I also commented a function call to
msg.addString()
, which internally does amemcpy
, the problem was gone. https://github.com/opentibiabr/canary/blob/b61cd9d4227220dd46c408a11f55c6217d8ba7eb/src/server/network/protocol/protocolgame.cpp#L4174-L4175Demo
https://github.com/opentibiabr/canary/assets/10242142/6196d41f-72a5-4cd5-85e9-53e19cb3b4a2
Note
Using rope or shovel works ok.
What OS are you seeing the problem on?
Linux
Code of Conduct