From ac2f98b846eba85ab3d9acb5bd0f355a404de86c Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Fri, 16 Oct 2009 03:32:30 -0400 Subject: * A hacky attempt at resolving mantis #4260. I think ODE was unable to allocate memory, and therefore the unmanaged wrapper call fails or worse.. there's some unmanaged resource accounting in the ODEPlugin for ODECharacter that isn't being done properly now. * The broken avatar may not be able to move, but it won't stop simulate from pressing on now. And, the simulator will try to destroy the avatar's physics proxy and recreate it again... but if this is what I think it is, it may not help. --- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Physics/OdePlugin') diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index bd81d50..bd05c92 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -1105,7 +1105,18 @@ namespace OpenSim.Region.Physics.OdePlugin public void UpdatePositionAndVelocity() { // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! - d.Vector3 vec = d.BodyGetPosition(Body); + d.Vector3 vec; + try + { + vec = d.BodyGetPosition(Body); + //throw new NullReferenceException("foo!"); + } + catch (NullReferenceException) + { + vec = new d.Vector3(Position.X, Position.Y, Position.Z); + base.RaiseOutOfBounds(_position); + } + // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) if (vec.X < 0.0f) vec.X = 0.0f; @@ -1137,7 +1148,16 @@ namespace OpenSim.Region.Physics.OdePlugin else { m_lastUpdateSent = false; - vec = d.BodyGetLinearVel(Body); + try + { + vec = d.BodyGetLinearVel(Body); + } + catch (NullReferenceException) + { + vec.X = _velocity.X; + vec.Y = _velocity.Y; + vec.Z = _velocity.Z; + } _velocity.X = (vec.X); _velocity.Y = (vec.Y); -- cgit v1.1 From 1f28c6208be1b3be1acca69f0ac8056d0ceecc06 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Fri, 16 Oct 2009 03:40:44 -0400 Subject: * Added a message for when the null reference exception occurs to make debugging easier. Without this, from the user's perspective.. they cannot move, fly or otherwise do anything physical and without a message on the console, it would be hard to tell that this is what is occurring. --- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Physics/OdePlugin') diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index bd05c92..e5458d4 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -1109,12 +1109,13 @@ namespace OpenSim.Region.Physics.OdePlugin try { vec = d.BodyGetPosition(Body); - //throw new NullReferenceException("foo!"); + } catch (NullReferenceException) { - vec = new d.Vector3(Position.X, Position.Y, Position.Z); - base.RaiseOutOfBounds(_position); + vec = new d.Vector3(_position.X, _position.Y, _position.Z); + base.RaiseOutOfBounds(_position); // Tells ScenePresence that there's a problem! + m_log.WarnFormat("[ODEPLUGIN]: Avatar Null reference for Avatar: {0}", m_name); } -- cgit v1.1 From 0079d0a7c423db6e95c04b9055127b53ae6a3622 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Fri, 16 Oct 2009 14:30:55 -0400 Subject: * One more attempt at the NullRef In The OdePlugin. This might fix it, but it will definitely get us closer to the root cause. --- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 2 +- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Physics/OdePlugin') diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index e5458d4..1fff846 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -1109,10 +1109,10 @@ namespace OpenSim.Region.Physics.OdePlugin try { vec = d.BodyGetPosition(Body); - } catch (NullReferenceException) { + _parent_scene.BadCharacter(this); vec = new d.Vector3(_position.X, _position.Y, _position.Z); base.RaiseOutOfBounds(_position); // Tells ScenePresence that there's a problem! m_log.WarnFormat("[ODEPLUGIN]: Avatar Null reference for Avatar: {0}", m_name); diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 083b7db..0e03e81 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -242,6 +242,7 @@ namespace OpenSim.Region.Physics.OdePlugin private readonly HashSet _taintedActors = new HashSet(); private readonly List _perloopContact = new List(); private readonly List _collisionEventPrim = new List(); + private readonly HashSet _badCharacter = new HashSet(); public Dictionary geom_name_map = new Dictionary(); public Dictionary actor_name_map = new Dictionary(); private bool m_NINJA_physics_joints_enabled = false; @@ -1677,6 +1678,14 @@ namespace OpenSim.Region.Physics.OdePlugin } } } + public void BadCharacter(OdeCharacter chr) + { + lock (_badCharacter) + { + if (!_badCharacter.Contains(chr)) + _badCharacter.Add(chr); + } + } public override void RemoveAvatar(PhysicsActor actor) { @@ -2975,6 +2984,18 @@ namespace OpenSim.Region.Physics.OdePlugin } } + lock (_badCharacter) + { + if (_badCharacter.Count > 0) + { + foreach (OdeCharacter chr in _badCharacter) + { + RemoveCharacter(chr); + } + _badCharacter.Clear(); + } + } + lock (_activeprims) { //if (timeStep < 0.2f) -- cgit v1.1 From d49424c4211cb9128c116c8a0a13d9873eee5176 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Fri, 16 Oct 2009 21:20:55 -0400 Subject: * After seeing it repeat over and over again.. again, We won't inform the scenepresence that there was an issue so it doesn't try to make the capsule again. I have a feeling that this is some kind of object leak. We'll know for sure.. soon. --- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Physics/OdePlugin') diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 1fff846..8002eb2 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -1114,7 +1114,7 @@ namespace OpenSim.Region.Physics.OdePlugin { _parent_scene.BadCharacter(this); vec = new d.Vector3(_position.X, _position.Y, _position.Z); - base.RaiseOutOfBounds(_position); // Tells ScenePresence that there's a problem! + //base.RaiseOutOfBounds(_position); // Tells ScenePresence that there's a problem! m_log.WarnFormat("[ODEPLUGIN]: Avatar Null reference for Avatar: {0}", m_name); } -- cgit v1.1 From 01051daaab27cf4c4b5e3d5e8066caa61cf769a6 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Fri, 16 Oct 2009 21:24:08 -0400 Subject: * One more tweak to inform the user that they may not be able to move until relogging. --- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Physics/OdePlugin') diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 8002eb2..1fff846 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -1114,7 +1114,7 @@ namespace OpenSim.Region.Physics.OdePlugin { _parent_scene.BadCharacter(this); vec = new d.Vector3(_position.X, _position.Y, _position.Z); - //base.RaiseOutOfBounds(_position); // Tells ScenePresence that there's a problem! + base.RaiseOutOfBounds(_position); // Tells ScenePresence that there's a problem! m_log.WarnFormat("[ODEPLUGIN]: Avatar Null reference for Avatar: {0}", m_name); } -- cgit v1.1 From 0d29614ca129a044f6fad01f5600c52a922b702c Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 19 Oct 2009 08:58:03 +0900 Subject: Formatting cleanup. --- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 4 ++-- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Physics/OdePlugin') diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 496e097..63bfc90 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -816,8 +816,8 @@ namespace OpenSim.Region.Physics.OdePlugin IntPtr vertices, indices; int vertexCount, indexCount; int vertexStride, triStride; - mesh.getVertexListAsPtrToFloatArray( out vertices, out vertexStride, out vertexCount ); // Note, that vertices are fixed in unmanaged heap - mesh.getIndexListAsPtrToIntArray( out indices, out triStride, out indexCount ); // Also fixed, needs release after usage + mesh.getVertexListAsPtrToFloatArray(out vertices, out vertexStride, out vertexCount); // Note, that vertices are fixed in unmanaged heap + mesh.getIndexListAsPtrToIntArray(out indices, out triStride, out indexCount); // Also fixed, needs release after usage mesh.releaseSourceMeshData(); // free up the original mesh data to save memory diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 0e03e81..92afe39 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -3799,7 +3799,7 @@ namespace OpenSim.Region.Physics.OdePlugin } public void start(int unused) - { + { ds.SetViewpoint(ref xyz, ref hpr); } #endif -- cgit v1.1