2

I am new to threads and have put together a basic command line application using pthread's. I use pthread_create passing a struct as the final param; starting a new thread which calls "void *thread_routine (void *arg)". I have made a few observations worth noting. - The program doesn't always provide the same results - about 10% of the time the program seg faults

What are some good techniques to use when debugging multi-threaded applications in c++?

Oliver Charlesworth
  • 267,707
  • 33
  • 569
  • 680
Joemie
  • 31
  • 4

3 Answers3

0

Watch for your shared memmory access and use logging to find errors.

jhruby
  • 268
  • 2
  • 6
0

Segfault is only the visible part of the iceberg. It might be a result of race conditions, and in this case you should focus on ensuring that threads are properly synchronized. Then the remaining segfault should be different than the ones of a single-threaded application.

UmNyobe
  • 22,539
  • 9
  • 61
  • 90
0

You can apposite debugging support tools such as GDB which work fine also for multi-threaded programs. Check out these links:

Community
  • 1
  • 1
Matteo
  • 7,924
  • 24
  • 84
  • 129