Replies: 2 comments 1 reply
-
Anything is possible, but if so, this would be the first time I heard about it. To diagnose this, it would be interesting to look at the native call stacks and see where exactly are the threads blocked. Or if it's possible to share the dump? If you can share the dump, it's probably better to do so via https://developercommunity.visualstudio.com/dotnet/report?ftype=problem. |
Beta Was this translation helpful? Give feedback.
-
Yes, Assembly.Load can cause deadlocks in certain scenarios. Assembly.Load is a method in the .NET Framework that loads an assembly into the current application domain. It can be called with a string that specifies the name of the assembly to load or with a byte array that contains the binary representation of the assembly. Deadlocks occur when two or more threads are blocked, waiting for each other to release resources. Deadlocks can occur when calling Assembly.Load if there are multiple threads loading assemblies simultaneously, and the assemblies have dependencies on each other. For example, suppose thread A is loading assembly X, which has a dependency on assembly Y. At the same time, thread B is loading assembly Y, which has a dependency on assembly X. If both threads are blocked waiting for the other to release the resources, a deadlock occurs, and the program becomes unresponsive. To avoid deadlocks when loading assemblies, you can use the AppDomain.AssemblyResolve event to load assemblies on demand and avoid loading them simultaneously. You can also use locking mechanisms to prevent multiple threads from loading assemblies simultaneously. It is important to note that deadlocks can occur in any multithreaded application, not just when using Assembly.Load. It is essential to design and test the application carefully to avoid deadlocks and ensure that it is thread-safe. |
Beta Was this translation helpful? Give feedback.
-
Hi,
We have a high throughput application that generates thousands of tasks per second doing some processing on aerospike records in parallel. It's all good when the load is relatively small, but when we want to activate 250k records in parallel (we have Semaphore which limits each batch at 1000) we start experiencing deadlock scenarios. I've created a dump file and I observed that 85.27% (according to Visual Studio analyzer) of the current tasks are all stuck with this call stack:
I know it sounds bizarre but I think because the load that we generate is not gradual but rather 1k at once, it might relate to Assembly.Load deadlocking so I wanted to contact you guys if you know of such a possibility?
Beta Was this translation helpful? Give feedback.
All reactions