Running multiple instances of BEPU is crashing

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Psykocyber
Posts: 8
Joined: Thu Mar 15, 2012 11:40 am

Running multiple instances of BEPU is crashing

Post by Psykocyber »

Hi

I'm currently using BEPU for a project where I need multiple instances of BEPU running in the same program at the same time, they are completely isolated with no interaction between them.
However, it's still crashing, usually in the deactivition manager in the add and remove functions. All instances of BEPU is single threaded.
Does BEPU support running multiple instances? And what can be done to solve this problem?

A bit more specific: For every entity for every frame, I apply a random impulse to it. And thus, it crashes. It also crash if I set AngularMomentum to some value.

Even more specific: It only crashes when using multiple instances and I call ApplyAngularImpulse AND AppleLinearImpulse
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Running multiple instances of BEPU is crashing

Post by Norbo »

Does BEPU support running multiple instances? And what can be done to solve this problem?
It should work just fine, but I have reproduced the problem. I'll post again with more information/a workaround/a fix when I know more.
Psykocyber
Posts: 8
Joined: Thu Mar 15, 2012 11:40 am

Re: Running multiple instances of BEPU is crashing

Post by Psykocyber »

Thanks, looking forward to your reply.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Running multiple instances of BEPU is crashing

Post by Norbo »

A quick status update: I'm still narrowing down possibilities. Unfortunately, this involves hundreds/thousands of automated tests. It might be a while :)
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Running multiple instances of BEPU is crashing

Post by Norbo »

Apparently, there exists a gap in the recycling of stale narrow phase pairs and pairs become available for reuse prematurely. Under normal circumstances, this gap cannot be exploited as it is within the execution of the engine. However, when running multiple updates in parallel, the shared resource pool will be accessed.

Incidentally, certain updateables that run within this gap (like character controllers) can trigger issues even without multithreading. This helps explain some very rare bugs I noticed in a separate project's character implementation :)

Now that I've finally identified the (likely) source of the issue, I should be able to get a fix into the development version in the next couple of days.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Running multiple instances of BEPU is crashing

Post by Norbo »

The development version contains a fix: http://bepuphysics.codeplex.com/SourceC ... evelopment

I've still got some more testing to do, but it looks solid.
Psykocyber
Posts: 8
Joined: Thu Mar 15, 2012 11:40 am

Re: Running multiple instances of BEPU is crashing

Post by Psykocyber »

Works perfectly with that update. Thank you for a quick update.
Post Reply