Jump to content

Deadlock in Thread::switchThread


photo

Recommended Posts

Posted

Hello,

I am using AsyncQueue (in Unigine 2.13.0.1) to trigger streaming of some node hierarchies, wait for it to finish in my callback, call takeNode and then in the next main thread frame do a node clone:

- Callback to be called in a background thread when node is ready: 
    AsyncQueue::takeNode
    lock
       push node into _pendingNodes
     unlock

- In the main thread:
    lock
       take and remove a node from _pendingNodes
     unlock
  node->clone() // This is where I got a deadlock

The lock/unlock are my own locks so I can access in thread-safe manner the array holding nodes that were just streamed in. I clone them only in the main thread but then for some node hierarchy I got Ungine deadlocking (just stalling the main thread) here:

This is the most common callstack:

image.thumb.png.c2adfc90bb5d811483cfd1f91650a99c.png

So when some sound source is cloned inside the hierarchy.
But sometimes it stalls in other callstack, but always when  on that SwitchToThread:

image.thumb.png.4231057b63962d13f3c58d38a4c9237d.png

From Win32 SDK I got this:

Note that the operating system will not switch to a thread that is being prevented from running only by concurrency control. For example, an I/O completion port or thread pool limits the number of associated threads that can run. If the maximum number of threads is already running, no additional associated thread can run until a running thread finishes. If a thread uses SwitchToThread to wait for one of the additional associated threads to accomplish some work, the process might deadlock.

But looking at current threads spawn by process they are not more than usual.

This happens only in release build, with or without a debugger attached.

Any idea what may cause this?

Kind Regards,
Adrian L.

Posted

Hi, and thank you for the fast response. Will check on 2.15 and come back with a response. As for testing on your end, I already have the source/application posted on the ticket system (for another issue), but you don't have yet the data (the node hierarchy that is causing this). Will check to see how can I share this with you.

Regards,
Adrian

×
×
  • Create New...