-
Notifications
You must be signed in to change notification settings - Fork 300
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
Pet: fix heap-use-after-free due to trying to unsummon an already unsummoned pet #478
Conversation
good find |
e18ef83
to
0388d21
Compare
The map is not trying to unsummon the pet though, it's removing it from the map - presumably because it has been unsummoned indeed. That's basically what Now, the call to Your change avoids the issue by having |
Thanks a lot for the clarifications! The same pet is indeed being added to the remove list twice (at least), but I wasn't able to debug it further than that. I'll revert this change and do as you said. |
Thanks! You don't even have to revert the change for that. Even with your change, |
Didn't manage to reproduce it again so far. I'll keep trying and update if it happens. |
I will add an assert to the codebase in this place. I am sure your code is valid but I think we need to treat the cause, not the symptom. Will keep this PR opened, whenver I add an assert, people come running with stack traces. |
Diagnostics for this PR: #478
Diagnostics for this PR: cmangos/mangos-wotlk#478
Diagnostics for this PR: cmangos/mangos-wotlk#478
Backtrace for the first unsummon call:
backtrace for the second unsummon call:
|
The packetlog doesn't show the same opcode being sent twice
so it's not some issue of repeat packets at least |
ahh, duh. the problem is Either My vote is on removing |
diff --git a/src/game/Entities/Pet.cpp b/src/game/Entities/Pet.cpp
index cf8f8e509..2be503a30 100644
--- a/src/game/Entities/Pet.cpp
+++ b/src/game/Entities/Pet.cpp
@@ -2441,8 +2441,6 @@ void Pet::ForcedDespawn(uint32 timeMSToDespawn, bool onlyAlive)
if (IsAlive())
SetDeathState(JUST_DIED);
- RemoveCorpse(true); // force corpse removal in the same grid
-
Unsummon(PET_SAVE_NOT_IN_SLOT, owner);
}
change the PR to this and it will work |
🍰 Pullrequest
Server kept crashing without crashlog, so I hooked it up to ASAN and got this:
Crashlog
From the very little I understand from this, Map is trying to unsummon a pet while it's already being unsummoned, causing memory corruption.
No way to reproduce, but it happened after letting celguar's Playerbots run for ~20 minutes.
This could just be due to some quirk of playerbots and not happen during normal usage, but even so I don't think this safeguard would hurt to have.
Proof
Issues
How2Test
Todo / Checklist