diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 4b8df370ea..171ab2e018 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -163,6 +163,8 @@ namespace OpenSim.Region.Environment.Scenes private Thread HeartbeatThread; private volatile bool shuttingdown = false; + private object m_deleting_scene_object = new object(); + #endregion #region Properties @@ -1823,7 +1825,11 @@ namespace OpenSim.Region.Environment.Scenes { //SceneObjectPart rootPart = group.GetChildPart(group.UUID); - group.RemoveScriptInstances(); + // Serialise calls to RemoveScriptInstances to avoid + // deadlocking on m_parts inside SceneObjectGroup + lock (m_deleting_scene_object) { + group.RemoveScriptInstances(); + } foreach (SceneObjectPart part in group.Children.Values) {