Crash when destroying body in OnEnter of TriggerCallback

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Crash when destroying body in OnEnter of TriggerCallback

Postby Lax » Mon Jun 18, 2018 3:35 pm

Hi,

I'm testing the dCustomTriggerManager.

When I use more then one thread for the newton and destroy a body inside the OnEnter method of the TriggerCallback I get an crash or a newton method will hang forever.

I tested two scenarios:
1. NewtonUpdate: The method: NewtonDestroyBody will never return
2. NewtonUpdateAsync: Before I destroy the body NewtonWaitForUpdateToFinish is called, which will hang forever.

I also have no Idea, if in the onEnter method of the trigger, a mutex is required or not.

When I set just one thread for newton, everything works fine.

Has somebody an idea, how to solve this situation?

Best regards
Lax
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 165
Joined: Sat Jan 08, 2011 8:24 am

Re: Crash when destroying body in OnEnter of TriggerCallback

Postby Julio Jerez » Mon Jun 18, 2018 3:41 pm

It may be broken, can it be reproduced in the sandbox?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crash when destroying body in OnEnter of TriggerCallback

Postby Lax » Tue Jun 19, 2018 3:13 pm

Yes, I added in the AlchimedesBuoyancy demo the following code in the TriggerCallback and set 4 Thread for simulation:
Code: Select all
void OnEnter(NewtonBody* const visitor)
{
   NewtonWaitForUpdateToFinish(this->m_controller->GetManager()->GetWorld());
   NewtonDestroyBody(visitor);
}

The application started to hang when a cube intersected the buoyancy volume.
Last edited by Lax on Tue Jun 19, 2018 3:22 pm, edited 1 time in total.
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 165
Joined: Sat Jan 08, 2011 8:24 am

Re: Crash when destroying body in OnEnter of TriggerCallback

Postby Julio Jerez » Tue Jun 19, 2018 3:22 pm

you say you added. do you mean that if I play the demo it will crash if I set to four threads?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crash when destroying body in OnEnter of TriggerCallback

Postby Lax » Tue Jun 19, 2018 3:34 pm

I tested again with one thread and four threads. The threads number does not matter in the sample application. The application starts to hang, when a cube does intersect the buoyancy volume.
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 165
Joined: Sat Jan 08, 2011 8:24 am

Re: Crash when destroying body in OnEnter of TriggerCallback

Postby Julio Jerez » Tue Jun 19, 2018 5:07 pm

wait a minute, I searched for this code and is in the demo.
Code: Select all
void OnEnter(NewtonBody* const visitor)
{
   NewtonWaitForUpdateToFinish(this->m_controller->GetManager()->GetWorld());
   NewtonDestroyBody(visitor);
}


are you saying that in your demo you are try to destroy a body form a call back?
That will most certainty generate a random crash.

I older versions it may not crash because the engine was place the object on a deferred list, but the has ground to big to keep baby system all these possible error and this thong at now on the client size

you should modify your code like tis
Code: Select all
void OnEnter(NewtonBody* const visitor)
{
   dCustomScopeLock lock (&m_lock);
        DefereectVector.Add (visitor);
}


Then after the Update you can iterate over he DefereectVector and calling
NewtonDestroyBody(DefereectVector[I]);
and rest the vector.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crash when destroying body in OnEnter of TriggerCallback

Postby Julio Jerez » Tue Jun 19, 2018 5:15 pm

I fixed a small potential bug, but that is no the reason for the crash or hang.
if you do what I explained it should be fine.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crash when destroying body in OnEnter of TriggerCallback

Postby Lax » Sat Jun 23, 2018 4:16 pm

Ok, thanks for the information. I will try It out.

Regards
Lax
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 165
Joined: Sat Jan 08, 2011 8:24 am


Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 7 guests