Skip to content

Commit

Permalink
Adjust cross-thread error message (#4181)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mag-nus authored May 17, 2024
1 parent 7618dbf commit 2498c62
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Source/ACE.Server/Entity/Landblock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,19 @@ private bool AddWorldObjectInternal(WorldObject wo)
{
if (CurrentLandblockGroup != null && CurrentLandblockGroup != LandblockManager.CurrentMultiThreadedTickingLandblockGroup.Value)
{
// Prevent possible multi-threaded crash
// The following scenario can happen rarely in ACE, all in the same call stack with no ActionQueue usage:
// Moster successfully lands an attack on a player that procs a cloak spell
// The code goes through and does the LaunchSpellProjectiles() which adds the spell projectiles to (presumably) the players landblock
// For some unknown reason, the LandblockGroup/Thread where the monster exists seems to be a different LandblockGroup/Thread where the spells are added to.
// Maybe there's a player death race condition? Maybe it's a teleport race condition? I dunno.
// Because this happens so rarely, and, it only seems to affect cloak projectiles, and, cloak projectiles are pretty benign, we simply don't add the object, and only log it as a warning.
if (wo.WeenieType == WeenieType.ProjectileSpell)
{
log.Warn($"Landblock 0x{Id} entered AddWorldObjectInternal in a cross-thread operation for a ProjectileSpell. This is normally not an issue unless it's happening more than once an hour.");
return false;
}

log.Error($"Landblock 0x{Id} entered AddWorldObjectInternal in a cross-thread operation.");
log.Error($"Landblock 0x{Id} CurrentLandblockGroup: {CurrentLandblockGroup}");
log.Error($"LandblockManager.CurrentMultiThreadedTickingLandblockGroup.Value: {LandblockManager.CurrentMultiThreadedTickingLandblockGroup.Value}");
Expand All @@ -842,10 +855,6 @@ private bool AddWorldObjectInternal(WorldObject wo)

log.Error("PLEASE REPORT THIS TO THE ACE DEV TEAM !!!");

// Prevent possible multi-threaded crash
if (wo.WeenieType == WeenieType.ProjectileSpell)
return false;

// This may still crash...
}
}
Expand Down

0 comments on commit 2498c62

Please sign in to comment.