I'm writing a C++ mulithread app. If any one of thread crashed need to find the exact thread with unique name. so that I can keep track of them during debugging. I difficult to find the exact thread with thread id.
can u suggest any other way to find which thread was crashed both windows and linux platform.
What is the core file size?
May be core file is getting discarded.
Try to set "ulimit -c unlimited" which will allow you to generate full core dump.
then use command: file coredumpfile, which will show you which program actually generated the core, just to make sure you are debugging the right core.
Then use the following command:
gdb -c coredumpfile ./YourProgram
then give command: "info threads" it will show you all the threads, usually the last thread is the one which crashed.
You can then debug individual thread by selecting the thread number you got in the last command
"thread 1" which will take you to that thread
or you can give command: "thread apply all bt" to see the back trace of all the threads.
or "thread apply threadno bt" to see the back trace of the last thread.
in the bt, you can see exactly where it crashed.
In the multithread programs, usually program crash because of invalid memory access, use share_pointer and locking as much as possible to control memory access.
There are some performance bottleneck for using those, but at least your program will not crash.
there is other tool too, valgrind is a very good tool to check the memory leaks and invalid read.