Skip to content
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

[Bug] - [CMANGOS-TBC] Event OnPlayerKilledByCreature Hook Sometimes Got Core Crash #452

Closed
betayi opened this issue Nov 10, 2023 · 6 comments

Comments

@betayi
Copy link

betayi commented Nov 10, 2023

Here is part of the coredumpctl gdb output:

Core was generated by `./mangosd'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 Unit::Kill (killer=0x0, victim=0x7fd6841ddb00, damagetype=<error reading variable: Cannot access memory at address 0x7fd6e9b818ec>,
spellInfo=<error reading variable: Cannot access memory at address 0x7fd6e9b818f8>, durabilityLoss=,
duel_hasEnded=) at /data/C-TBC/src/game/Entities/Object.h:484
484 Creature* ToCreature() { if (GetTypeId() == TYPEID_UNIT) return reinterpret_cast<Creature*>(this); else return NULL; }
[Current thread is 1 (LWP 477840)]

in Unit.cpp the only place invoke ToCreature() is:

#ifdef BUILD_ELUNA
if (Creature* killerCre = killer->ToCreature())
{
// used by eluna
if (Player* killed = victim->ToPlayer())
sEluna->OnPlayerKilledByCreature(killerCre, killed);
}
#endif

So, is this the core crash reason ? @Niam5

@Niam5
Copy link
Contributor

Niam5 commented Nov 10, 2023 via email

@betayi
Copy link
Author

betayi commented Nov 10, 2023

in dumplog , the crash was triggered before hook function, so lua scripts defined registerplayerevent can not be execute here,

the condition is hard to say , cuz it should be a special killer , must not a creature.

@Rochet2
Copy link
Member

Rochet2 commented Nov 10, 2023

@Niam5 Looks like killer can be nullptr as seen here, but its not checked if it is null here.

I think the killer might be nullptr if player dies from a spell casted by a gameobject that has no owner. In this case the caster cannot be the gameobject or any other entity as it must be Unit and gameobject is not an Unit.
I guess maybe a fireplace that damages player could cause this?
Looks like some AOE or DOT spells call GetAffectiveCasterOrOwner which might result in nullptr as caster, so spell damage to player will be done by nullptr which then crashes the code as killer is nullptr.

@Niam5
Copy link
Contributor

Niam5 commented Nov 10, 2023 via email

@Niam5
Copy link
Contributor

Niam5 commented Nov 23, 2023

Update your core to c5eb05a0e04d6638121def394e5d1b7bf1641ac5 and see if it still crashes please.

@betayi
Copy link
Author

betayi commented Nov 30, 2023

works. no more crash with this info.

@betayi betayi closed this as completed Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants