How to debug deadlock using python?

I am developing a multi-threaded application that is deadlocked.

I am using Visual C ++ Express 2008 to track a program. When a deadlock occurs, I simply pause the program and trace. I found that when a deadlock occurs on my C ++ extension, there will be two threads called python.

They all use Queue in python code, so I think the deadlock could be caused by Queue. But, however, as soon as the extension goes into python code, I see nothing but asm code and binary code from the VC ++ debugger.

I would like to know if there is a way to drop the call stack from python code after I paused the program? And how can I find out which locks in threads caused a deadlock?

+4
source share
1 answer

If you can compile your extension with gcc (e.g. using Cygwin ), you can use gdb and pystack gdb macro to get Python stacks in this situation. I don't know if it is possible to do something equivalent to pystack in Visual C ++ Express, but you can get some ideas from the implementation of the pystack macro.

Since you mention that you only see asm / binary in the VC ++ debugger, you need to make sure that you compile Python with debugging symbols. If VC ++ is still showing asm, perhaps you need to tell VC ++ where the source files are (sorry, they have not used VC ++ in years, so I can’t say what you might need if that is the case).

You can also get important information by adding a lot of logging codes to your code, both on the Python side and on your C ++ extension.

In any case, I'm pretty sure that the deadlocks are not associated with the queue, but with your own code.

+5
source

Source: https://habr.com/ru/post/893306/


All Articles