how to deliberately cause deadlock in test cases to guard concurrent bug steadily?

68 views Asked by At

Imagine I have a complex test case which can cause two threads deadlock occasionally. It's not suiteable, I think, to run in CI for guarding concurrent bugs. I want to write a simple test case to cause that deadlock with very high likelihood according to the threads' stacktraces.

However it's still hard to reproduce the deadlock in my case due to scheduling of threads in OS. How do I make sure the deadlock nearly always happens in my case until the bug has been fixed ? I don't know if there're some tricks that can implement it such as changing OS parameter, setting up specific points for yielding or sleeping.

0

There are 0 answers