From 2498c623cbd7b591860ec2ee82e2cd1c1e95fcb3 Mon Sep 17 00:00:00 2001 From: Mag-nus <Mag-nus@users.noreply.github.com> Date: Fri, 17 May 2024 19:07:43 +0000 Subject: [PATCH] Adjust cross-thread error message (#4181) --- Source/ACE.Server/Entity/Landblock.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Source/ACE.Server/Entity/Landblock.cs b/Source/ACE.Server/Entity/Landblock.cs index f192a5f1df..43c0a438f1 100644 --- a/Source/ACE.Server/Entity/Landblock.cs +++ b/Source/ACE.Server/Entity/Landblock.cs @@ -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}"); @@ -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... } }