From: Christopher Yeoh <cyeoh@au1.ibm.com>

This patch addresses mantis bug 2576.

 http://opensimulator.org/mantis/view.php?id=2576

Briefly, if you call llDie from many scripts at the same time (say a
build is cleaning up excess objects) then OpenSim deadlocks. Avatars
are unable to move, and whilst the console is active you can't do much
without it also locking up. This only occurs with the XEngine script
engine enabled.

I have attached a patch which works, but I'm not sure its the right way
to address the problem. The fundamental problem is that a lock on a
SceneObjectGroup's m_parts is taken when the object is deleted, a
callback to the script engine occurs and a fair way down the callchain,
potentially there are locks taken on several other SceneObjectGroup's
m_parts. Deadlock then occurs if you get unlucky enough
to get in the situation where with several llDie's are called and
SceneObjectGroups
have taken a lock on their own m_parts, and end up waiting on each
other's
locks to become available.

The patch adds a lock at a high level so that that the removal of script
instances
from an object only occurs once per scene at a time. This avoids the
potential
of deadlock. Theoretically there could be some performance hit but
AFAICT
the path taken is not a common occurrence.

Would welcome any suggestions for a better solution, otherwise feel free
to apply  :-)

Note this patch was built against the 0.6.0 freeze as trunk was
rather broken for me this morning (creating a script killed the client
connection).
0.6.1-post-fixes
Sean Dague 2008-11-10 12:42:22 +00:00
parent 22b70495ab
commit bfc2d8c231
1 changed files with 7 additions and 1 deletions

View File

@ -164,6 +164,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
@ -1824,7 +1826,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)
{