New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Very rare server crash on creature events. #2570
Comments
@raymondtfr when i discovered this bug i had checked that the classes and functions were 100% aligned with the master. This was a few months ago. I'll check again. I fixed this bug on my server but it was not an ideal solution. I posted this bug here so that some acceptable solution may come up for everyone who may have come to suffer from it. |
As I said in the previous post, you have got to use the issue template so we can make sure this issue is present in this repository and not a side effect of sources that has been modified. Anyway, is the crash you posted above from months ago like you said? |
@raymondtfr 2º Mine was fixed months ago with a bad solution. 3º I will check again if this happens with the master repo, i'm downloading this now. 4º This GDB LOG is a recent crash where it happened in a server of my friend. I identified that the log was the same as mine and decided to post here already so that nobody suffers more with this bug. |
probably this: void Combat::doCombat(Creature* caster, Creature* target) const
{
//target combat callback function
if (params.combatType != COMBAT_NONE) {
CombatDamage damage = getCombatDamage(caster, target);
if (damage.primary.type != COMBAT_MANADRAIN) {
doCombatHealth(caster, target, damage, params);
} else {
doCombatMana(caster, target, damage, params);
}
} else {
doCombatDefault(caster, target, params);
}
}
void Combat::doCombat(Creature* caster, const Position& position) const
{
//area combat callback function
if (params.combatType != COMBAT_NONE) {
CombatDamage damage = getCombatDamage(caster, nullptr);
if (damage.primary.type != COMBAT_MANADRAIN) {
doCombatHealth(caster, position, area.get(), damage, params);
} else {
doCombatMana(caster, position, area.get(), damage, params);
}
} else {
CombatFunc(caster, position, area.get(), params, CombatNullFunc, nullptr);
}
} as we do not check if caster is valid before we apply the damage and just push the dangling pointer onwards. |
I did more than 2 hours of testing here and discovered new things and discovered the specific situations, I will edit the issue with this informations: Discovered: It was discovered that for the bug to occur, one must call the "monster: remove ()" within a creature with a registered event (creaturescripts), the tests were done within the "onHealthChange" event. Basic solution: Do not do it. *This issue can be closed. Because in my internal investigations, that lasted hours they ended up verifying that it was something not of the source, but of a bad programming in lua. I'm sorry for that! |
Hello Guys! I have discovered, after hours and hours of testing. I discovered the error and the "ideal solution" i will post here and you can fix them. SPELLS.CPP () bool CombatSpell::castSpell(Creature* creature, Creature* target)
{
if (!creature || !target) // added this line
return false; // added this line
if (scripted) {
LuaVariant var;
if (combat->hasArea()) {
var.type = VARIANT_POSITION;
if (needTarget) {
var.pos = target->getPosition();
} else if (needDirection) {
var.pos = Spells::getCasterPosition(creature, creature->getDirection());
} else {
var.pos = creature->getPosition();
}
} else {
var.type = VARIANT_NUMBER;
var.number = target->getID();
}
return executeCastSpell(creature, var);
}
if (combat->hasArea()) {
if (needTarget) {
combat->doCombat(creature, target->getPosition());
} else {
return castSpell(creature);
}
} else {
combat->doCombat(creature, target);
}
return true;
} Sorry because i never had used github before, and i'm starting now... |
So is this a bug in master or not? Because you say it needs a fix and you close the issue too. |
Yes, its a bug in master. It occurs in very specific and rare situations where monsters must be in very specific situations as well. |
Steps to reproduce
Create a monster and make it "active". That means letting the monster attack another monster with (SPELLS) *The target monster tested here, have an event onHealthChange.
Now remove the target monster with this code:
Expected behaviour
Remove the monster without major problems
Actual behaviour
If the monster is removed at the exact moment it is dropping a spell the server crashes. (Important this was only tested with spells in area).
Environment
Linux - Ubuntu 18
GDB LOGS:
The text was updated successfully, but these errors were encountered: