When GDB attach a task, gdb hangs dead if too many threads are created, and the GDB version is upgraded or set to Non-stop mode to resolve the problem.
I fought with similar gdb issues for a while. My case is having lots of threads spawned this executed few functions and then exited.
It appears if a thread exits too fast and there ' s lots of these happening sometimes gdb cannot keep up and when it FAI LS, it fails with style as in crashes:) I think it tries to attach to a thread that's already done as per the error message.
I See this as a issue in GDB 6.5 to 7.6 and still happening. Did not a try with older versions.
My Advice is a look for this with case or similar. Once I changed my design to has a thread serving a queue of requests gdb works flawlessly.
Design Wise is healthier to has already created threads that digest actions than always spawning new threads.
still same code debugs without a problem on the Visual Studio so I do has to say that was a small disappointment to me wit H regards to GDB.
I use Eclipse and looking at the GDB traces (usually enabled by default) would give you a better hint of where GDB fails. One of the buttons on the console shows you the GDB trace.
Https://stackoverflow.com/questions/16814706/how-does-gdb-attach-to-multi-threaded-process
Why GDB crash if create too many threads?