Page 1 of 1

Running multiple instances of BEPU is crashing

Posted: Thu Mar 15, 2012 12:47 pm
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

Re: Running multiple instances of BEPU is crashing

Posted: Thu Mar 15, 2012 9:09 pm
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.

Re: Running multiple instances of BEPU is crashing

Posted: Fri Mar 16, 2012 11:48 am
by Psykocyber
Thanks, looking forward to your reply.

Re: Running multiple instances of BEPU is crashing

Posted: Wed Mar 21, 2012 12:34 am
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 :)

Re: Running multiple instances of BEPU is crashing

Posted: Wed Mar 21, 2012 9:16 am
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.

Re: Running multiple instances of BEPU is crashing

Posted: Thu Mar 22, 2012 1:28 am
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.

Re: Running multiple instances of BEPU is crashing

Posted: Thu Mar 22, 2012 2:12 pm
by Psykocyber
Works perfectly with that update. Thank you for a quick update.