diff options
| author | Giacomo Pozzoni <giacomopoz@gmail.com> | 2020-05-16 09:06:03 +0000 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2022-01-04 15:33:04 +0100 |
| commit | 9cb01a79046fce3f76835bb68bf66e4f3079e4bc (patch) | |
| tree | c5efcb9271d782e828399e197f6077e54b791c59 /src/server/game/Entities | |
| parent | 2256735a7765bbbd6383739b988db84761520233 (diff) | |
Fixes/3.3.5 aura infinite loop (#24631)
* Core/Auras: Attempt to fix infinite loop with aura 18950 on map unload
* Core/Auras: Log a detailed error and assert when failing to remove all auras after a few tries
* Code cleanup
* Fix build warnings
* Fix more build warnings
(cherry picked from commit bd2d60c2676a1d7e843a2a5673b8216bad0768c7)
Diffstat (limited to 'src/server/game/Entities')
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 6537c31c890..c1ff6556ed4 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -4035,7 +4035,7 @@ void Unit::RemoveAllAuras() { // this may be a dead loop if some events on aura remove will continiously apply aura on remove // we want to have all auras removed, so use your brain when linking events - while (!m_appliedAuras.empty() || !m_ownedAuras.empty()) + for (int counter = 0; !m_appliedAuras.empty() || !m_ownedAuras.empty(); counter++) { AuraApplicationMap::iterator aurAppIter; for (aurAppIter = m_appliedAuras.begin(); aurAppIter != m_appliedAuras.end();) @@ -4044,6 +4044,37 @@ void Unit::RemoveAllAuras() AuraMap::iterator aurIter; for (aurIter = m_ownedAuras.begin(); aurIter != m_ownedAuras.end();) RemoveOwnedAura(aurIter); + + const int maxIteration = 50; + // give this loop a few tries, if there are still auras then log as much information as possible + if (counter >= maxIteration) + { + std::stringstream sstr; + sstr << "Unit::RemoveAllAuras() iterated " << maxIteration << " times already but there are still " + << m_appliedAuras.size() << " m_appliedAuras and " << m_ownedAuras.size() << " m_ownedAuras. Details:" << "\n"; + sstr << GetDebugInfo() << "\n"; + + if (!m_appliedAuras.empty()) + { + sstr << "m_appliedAuras:" << "\n"; + + for (std::pair<uint32 const, AuraApplication*>& auraAppPair : m_appliedAuras) + sstr << auraAppPair.second->GetDebugInfo() << "\n"; + } + + if (!m_ownedAuras.empty()) + { + sstr << "m_ownedAuras:" << "\n"; + + for (std::pair<uint32 const, Aura*>& auraPair : m_ownedAuras) + sstr << auraPair.second->GetDebugInfo() << "\n"; + } + + TC_LOG_ERROR("entities.unit", "%s", sstr.str().c_str()); + ABORT_MSG("%s", sstr.str().c_str()); + + break; + } } } |
