• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.2 Gesior, Kondra stat system crash

There is nothing about server stats. It crashed on sending packet to player about HP regeneration (ex. for eating food):
Code:
#0  ProtocolGame::sendStats (this=0x555555ac3c10) at /home/debian/server/src/protocolgame.cpp:1214
        msg = <error reading variable msg (value of type `NetworkMessage' requires 187696 bytes, which is more than max-value-size)>
#1  0x00005555556e948d in Player::sendStats (this=0x7fffb54bc500) at /home/debian/server/src/player.cpp:1111
No locals.
#2  Player::changeHealth (this=0x7fffb54bc500, healthChange=<optimized out>, sendHealthChange=<optimized out>) at /home/debian/server/src/player.cpp:3911
No locals.
#3  0x00005555555c2b6a in ConditionRegeneration::executeCondition (this=0x7fffdc6469f0, creature=0x7fffb54bc500, interval=200) at /home/debian/server/src/condition.cpp:756
        realHealthGain = <optimized out>
#4  0x00005555555d6a0f in Creature::executeConditions (this=this@entry=0x7fffb54bc500, interval=interval@entry=200) at /home/debian/server/src/creature.cpp:1372
        it = <optimized out>
        condition = 0x7fffdc6469f0
        __for_range = std::__cxx11::list = {[0] = 0x7fffdc6469f0, [1] = 0x7fffde5650c0, [2] = 0x7fffe48ad250, [3] = 0x7fffe5792450, [4] = 0x7fffddd2a170, [5] = 0x7fffcba9e3a0, [6] = 0x7fffe7847b50, [7] = 0x7fffe564c600}
        tempConditions = std::__cxx11::list = {[0] = 0x7fffdc6469f0, [1] = 0x7fffde5650c0, [2] = 0x7fffe48ad250, [3] = 0x7fffe5792450, [4] = 0x7fffddd2a170, [5] = 0x7fffcba9e3a0, [6] = 0x7fffe7847b50, [7] = 0x7fffe564c600}
#5  0x00005555555f818f in Game::checkCreatures (this=0x5555559e8840 <g_game>, index=<optimized out>) at /home/debian/server/src/game.cpp:3582
Probably this player does not exist anymore or he has no connection. You can try to debug it with gdb:
Code:
p (Player*) 0x7fffb54bc500
p $1.name
If both commands work, it should show player name. If it does not, it means player is not in RAM anymore, but for some reason is still on list of 'creatures to check'.

You can also do same check for connection (if you run it after running check for Player without gdb restart, it will be different number than $1, probably $3):
Code:
p (ProtocolGame*) 0x555555ac3c10
p $1.player
It should some some address, probably 0x7fffb54bc500.

It crashed on 1214 line of protocolgame.cpp. Post this file, so we can check what can be wrong with it.
 
Last edited:
There is nothing about server stats. It crashed on sending packet to player about HP regeneration (ex. for eating food):
Code:
#0  ProtocolGame::sendStats (this=0x555555ac3c10) at /home/debian/server/src/protocolgame.cpp:1214
        msg = <error reading variable msg (value of type `NetworkMessage' requires 187696 bytes, which is more than max-value-size)>
#1  0x00005555556e948d in Player::sendStats (this=0x7fffb54bc500) at /home/debian/server/src/player.cpp:1111
No locals.
#2  Player::changeHealth (this=0x7fffb54bc500, healthChange=<optimized out>, sendHealthChange=<optimized out>) at /home/debian/server/src/player.cpp:3911
No locals.
#3  0x00005555555c2b6a in ConditionRegeneration::executeCondition (this=0x7fffdc6469f0, creature=0x7fffb54bc500, interval=200) at /home/debian/server/src/condition.cpp:756
        realHealthGain = <optimized out>
#4  0x00005555555d6a0f in Creature::executeConditions (this=this@entry=0x7fffb54bc500, interval=interval@entry=200) at /home/debian/server/src/creature.cpp:1372
        it = <optimized out>
        condition = 0x7fffdc6469f0
        __for_range = std::__cxx11::list = {[0] = 0x7fffdc6469f0, [1] = 0x7fffde5650c0, [2] = 0x7fffe48ad250, [3] = 0x7fffe5792450, [4] = 0x7fffddd2a170, [5] = 0x7fffcba9e3a0, [6] = 0x7fffe7847b50, [7] = 0x7fffe564c600}
        tempConditions = std::__cxx11::list = {[0] = 0x7fffdc6469f0, [1] = 0x7fffde5650c0, [2] = 0x7fffe48ad250, [3] = 0x7fffe5792450, [4] = 0x7fffddd2a170, [5] = 0x7fffcba9e3a0, [6] = 0x7fffe7847b50, [7] = 0x7fffe564c600}
#5  0x00005555555f818f in Game::checkCreatures (this=0x5555559e8840 <g_game>, index=<optimized out>) at /home/debian/server/src/game.cpp:3582
Probably this player does not exist anymore or he has no connection. You can try to debug it with gdb:
Code:
p (Player*) 0x7fffb54bc500
p $1.name
If both commands work, it should show player name. If it does not, it means player is not in RAM anymore, but for some reason is still on list of 'creatures to check'.

You can also do same check for connection (if you run it after running check for Player without gdb restart, it will be different number than $1, probably $3):
Code:
p (ProtocolGame*) 0x555555ac3c10
p $1.player
It should some some address, probably 0x7fffb54bc500.

It crashed on 1214 line of protocolgame.cpp. Post this file, so we can check what can be wrong with it.
Commands didnt worked. But how its possible that he has no connection or doesnt exist and he executed hp regeneration? That makes no sense

1214
C++:
void ProtocolGame::sendStats()
{
    NetworkMessage msg = NetworkMessage(getConnection()->getHeader); //this code line is 1214
    AddPlayerStats(msg);
    writeToOutputBuffer(msg);
}
 
NetworkMessage msg = NetworkMessage(getConnection()->getHeader); //this code line is 1214
IDK where you get this code, but I see it second time in last few weeks. Last time also in crash report.
Never seen it in any public engine. All public engines have NetworkMessage(); without parameter to create packet object.

This line expects getConnection() to exist (to read ->getHeader), but in given moment (ex. during player kick/death/exit) it's not guaranteed that connection still exist. If it does not exist, getConnection()->getHeader will crash server.
This code should be protected by:
C++:
if (!getConnection()) {
    return;
}
but there are probably around 100 NetworkMessage msg = NetworkMessage(getConnection()->getHeader); in protocolgame.cpp and maybe it would be easier to edit NetworkMessage to make it work without parameter and do not call getConnection()->getHeader.
 
IDK where you get this code, but I see it second time in last few weeks. Last time also in crash report.
Never seen it in any public engine. All public engines have NetworkMessage(); without parameter to create packet object.

This line expects getConnection() to exist (to read ->getHeader), but in given moment (ex. during player kick/death/exit) it's not guaranteed that connection still exist. If it does not exist, getConnection()->getHeader will crash server.
This code should be protected by:
C++:
if (!getConnection()) {
    return;
}
but there are probably around 100 NetworkMessage msg = NetworkMessage(getConnection()->getHeader); in protocolgame.cpp and maybe it would be easier to edit NetworkMessage to make it work without parameter and do not call getConnection()->getHeader.
There is exactly 79 NetworkMessage msg = NetworkMessage(getConnection()->getHeader); basically someone told me long time ago its networkMessage object array issue.
And how could i edit NetworkMessage to make it work without parameter getConnection()->getHeader?
 
Last edited:
sendStats you have provided is not stat system you are thinking about 🤷‍♂️
Yea noticed that probably miss understood it with gesiors/kanrah stat system since it was similar words and was latest comit i installed after noticing increased crashes after that change so though it was the reason
 
IDK where you get this code, but I see it second time in last few weeks. Last time also in crash report.
Never seen it in any public engine. All public engines have NetworkMessage(); without parameter to create packet object.

This line expects getConnection() to exist (to read ->getHeader), but in given moment (ex. during player kick/death/exit) it's not guaranteed that connection still exist. If it does not exist, getConnection()->getHeader will crash server.
This code should be protected by:
C++:
if (!getConnection()) {
    return;
}
but there are probably around 100 NetworkMessage msg = NetworkMessage(getConnection()->getHeader); in protocolgame.cpp and maybe it would be easier to edit NetworkMessage to make it work without parameter and do not call getConnection()->getHeader.
but here is your solution?
add connection checks before calling getHeader
 
but here is your solution?
add connection checks before calling getHeader
Yea but what i mean is where NetworkMessage like every NetworkMessage msg = NetworkMessage(getConnection()->getHeader); or somekind of function?
 
Back
Top