Jump to content

How thread-safe is WorldNode::getIntersection


photo

Recommended Posts

Posted

I have the following situation:

In my application there are 2 important threads (there are more, but only 2 are involved in the application): One thread that periodically calls WorldNode::getIntersection (well, it calls WorldInterface::getIntersection) in order to perform calculations based on the location of the player and another thread that does everything else (rendering, drawing graphics, handling user input, etc).

The application crashes at random (sometimes after 5 minutes, sometimes after an hour), but a core dump always reveals that the crash was caused by a SIGABRT raised from WorldNode::getIntersection.

Since this happens at random, I figure its thread-related (i.e.: Thread1 is calling a getIntersection, just as Thread2 is updating something).

Can someone verify / refute this. Alternate theories on why this happens are welcome.

I'm using Unigine V2.3.

Posted

Hi kbrodie,

You are correct, World::getIntersection is not thread save, it uses spatial tree, that can be changed while engine is updating and unfortunately there are no locks there.  You can add lock for calling this function and for engine update function, or just call it from engine thread.

Posted

If I add locks around the spatial tree, will it solve my problem, or are there other factors that need to be locked before it's thread safe?

×
×
  • Create New...