Sun Java Solaris Communities My SDN Account Join SDN
 
Downloads

Sun Studio Express - Thread Analyzer FAQ

 

Contents

  1. What is the the Thread Analyzer and who should use it?
  2. On what platforms is the Thread Analyzer supported?
  3. Where are the man pages and other docs for this release?
  4. What is a data race?
  5. What is deadlock?
  6. Can the Thread Analyzer detect both data races and deadlocks in the same experiment?
  7. Do I need to instrument my program for data race detection?
  8. Do I need to instrument my program for deadlock detection?
  9. Does the Thread Analyzer detect data races at compile-time or at runtime?
  10. Does the Thread Analyzer detect deadlocks at compile-time or at runtime?
  11. Can the Thread Analyzer detect data races in OpenMP applications? What about POSIX or Solaris thread applications?
  12. Can the Thread Analyzer detect deadlocks in OpenMP applications? What about POSIX or Solaris thread applications?
  13. Can the Thread Analyzer detect data races between different processes (for example, between different MPI processes)?
  14. Is the Thread Analyzer able to find all data races in a program?
  15. Why does the Thread Analyzer report different data races in different runs of the same program?
  16. Why does the Thread Analyzer report data races that do not exist in my application? How do I remove them?
  17. What is libtha.so and what does it do?
  18. Why does only one access of a data race show a full call stack?
  19. How do I know whether a data race is benign or not?
  20. Can I use the Performance Analyzer to read data race experiment results?
  21. Why do I get an error message saying that the compiler option -xinstrument=datarace is wrong when I use it with cc/CC/f90?
  22. Why do I get an error message when I use the er_print utility which says the races command is invalid?
  23. Why do I get an error message saying that -r is not recognized when I run collect -r on?
  24. How do I report a bug or share my Thread Analyzer experience with others?


  1. What is the Thread Analyzer and who should use it?
  2. The Thread Analyzer detects is a Sun Studio tool that detects data races and (potential and actual) deadlocks that occur during a multi-threaded process.


  3. On what platforms is the Thread Analyzer supported?
  4. The Thread Analyzer is available on the following hardware and operating systems:

    • The SPARC(R) v8plus, v8plusa, v8plusb, v9, v9a, and v9b architectures
    • The Intel(R) x86 and AMD(R) x64 platforms
    • The Solaris 9 and Solaris 10 operating systems
    • The SuSE Linux Enterprise Server 9 and the Red Hat Enterprise Linux 4 operating systems


  5. Where are the man pages and other docs for this release?
  6. A Getting Started Guide, a tutorial on using the Thread Analyzer for data race detection, and , a tutorial on using the Thread Analyzer for deadlock detection have been prepared for this preliminary release. There is also a general Thread Analyzer Information Page.

    The man pages in the binary Sun Studio Express release have not been updated, and are the man pages for the Sun Studio 11 release. The following man pages have been created or updated specifically for this preliminary release of the Thread Analyzer:



  7. What is a data race?
  8. A data race occurs when two or more threads in a process access the same memory location concurrently, at least one of the accesses is for writing, and the threads are not using any exclusive locks to control their accesses to that memory.

    A data race may result in non-deterministic program behavior and incorrect execution. Bugs caused by data races are notoriously difficult to detect by hand. The Thread Analyzer keeps track of data accesses in a multi-threaded program at runtime, and reports data races that have been encountered. By automatically detecting data races, the tool relieves the programmer from the laborious task of debugging the program and eases the task of multi-threaded programming.


  9. What is deadlock?
  10. Deadlock describes a condition where two or more threads are blocked (hang) forever, waiting for each other. Suppose we have a process with two or more threads. A deadlock occurs when the following three conditions hold:

    • Threads already holding locks request new locks,
    • The requests are made concurrently, and
    • Two or more threads form a circular chain where each thread waits for a lock that the next thread in the chain holds.
    Here is an example of a deadlock condition:

    Thread 1: holds lock A, requests lock B
    Thread 2: holds lock B, requests lock A

    A deadlock can be of two types: A "potential deadlock" or an "actual deadlock". A potential deadlock is a deadlock that did not occur in a given run, but can occur in different runs of the program depending on the timings of the requests for locks by the threads. An actual deadlock is one that actually occured in a given run of the program. An actual deadlock causes the threads involved to hang, but may or may not cause the whole process to hang.


  11. Can the Thread Analyzer detect both data races and deadlocks in the same experiment?
  12. Yes. Use collect -r all or collect -r race,deadlock to create an experiment for both data race and deadlock detection. The program needs to be instrumented for data race detection. Refer to the Getting Started Guide for more information.


  13. Do I need to instrument my program for data race detection?
  14. Yes. You can instrument your program for data race detection by compiling it with the -xinstrument=datarace compiler option. Refer to the Getting Started Guide for more information.


  15. Do I need to instrument my program for deadlock detection?
  16. No. You do not need to instrument your program for deadlock detection.


  17. Does the Thread Analyzer detect data races at compile-time or at runtime?
  18. The Thread Analyzer detects data races at runtime. At compile-time, the compiler inserts instrumentation code into the executable, so data races can be detected at runtime. To detect data races at runtime, run the instrumented executable using the collect command.


  19. Does the Thread Analyzer detect deadlocks at compile-time or at runtime?
  20. The Thread Analyzer detects (potential and actual) deadlocks at runtime, by keeping track of all the lock/unlock operations by the threads. No instrumentation of the code is required for deadlock detection. Simply run the executable using the collect command.


  21. Can the Thread Analyzer detect data races in OpenMP applications? What about POSIX or Solaris thread applications?
  22. The Thread Analyzer can detect data races that occur in code that is written using the POSIX thread API, the Solaris Operating System(R) thread API, OpenMP directives, Sun parallel directives, Cray(R) parallel directives, or a mix of these.


  23. Can the Thread Analyzer detect deadlocks in OpenMP applications? What about POSIX or Solaris thread applications?
  24. The Thread Analyzer can detect (potential and actual) deadlocks that occur in code that is written using the POSIX thread API, the Solaris Operating System(R) thread API, OpenMP directives, Sun parallel directives, Cray(R) parallel directives, or a mix of these.


  25. Can the Thread Analyzer detect data races between different processes (for example, between different MPI processes)?
  26. Not yet. The Thread Analyzer currently only detects data races between different threads spawned from a single process.


  27. Is the Thread Analyzer able to find all data races in a program?
  28. No. The Thread Analyzer detects data races at runtime. Since the exact runtime behavior of a program depends on a variety of factors (input data-set used, the scheduling of threads by the Operating System, etc.), not all data races in a program may be detected.

    Note that the Thread Analyzer is not a verification tool, but is a checking tool. If the Thread Analyzer does not report any races, that does not imply that the program is race-free.

    Use the Thread Analyzer with different numbers of threads and with different input data-sets and repeat experiments with a single data set to maximize the tool's chance of detecting data races.


  29. Why does the Thread Analyzer report different data races in different runs of the same program?
  30. The exact run-time behavior of a program depends on a variety of factors, including the scheduling of threads by the Operating System. The data race detection module of the Thread Analyzer uses heuristics to improve performance. As a result, the Thread Analyzer may not report all data races that it can detect. The Thread Analyzer guarantees, however, that if it detects that a memory location is involved in one or more data races, then it will report at least one of those data races.


  31. Why does the Thread Analyzer report data races that do not exist in my application? How do I remove them?
  32. In some cases, the Thread Analyzer may report data races that never actually occur in the program. These are called false positives, which usually happen when a user-implemented synchronization is used or when memory is recycled between threads. For example, if your code includes hand-coded assembly that implements spin locks, the Thread Analyzer will not recognize these synchronization points. Please see the a tutorial on Using the Thread Analyzer for a detailed description of false positives and examples of how to remove them through user API calls.


  33. What is libtha.so and what does it do?
  34. libtha.so is a library that satisfies the entry points for the data race-detection instrumentation calls and user API calls. It is linked automatically when a program is compiled and linked with -xinstrument=datarace. See the libtha(3) man page for more information.


  35. Why does only one access of a data race show a full call stack?
  36. This is a limitation of Express 2 build. Use Express 3 or later build 


  37. How do I know whether a data race is benign or not?
  38. There is no hard and fast rule to determine this. You need to inspect the code of the program, and determine whether a data race is benign or not based on the logic involved, the type of variable, the machine architecture, etc.


  39. Can I use the Performance Analyzer to read data race experiments?
  40. Yes, though the Performance Analyzer displays all of the traditional performance analysis tabs as well as the new Races, Dual Source, and Race Detail tabs. The tha interface is streamlined for data race detection and does not display the traditional Analyzer tabs.


  41. Why do I get an error message saying that the compiler option -xinstrument=datarace is wrong when I use it with cc/CC/f90?
  42. You are using an older version of Sun Studio that does not support the Thread Analyzer. Check the version of Sun Studio that you are using by typing: cc -Version
    The version date displayed should be no older than June 2006.


  43. Why do I get an error message when I use the er_print utility which says the races command is invalid?
  44. You are using an older version of Sun Studio that does not support the Thread Analyzer. Check the version of Sun Studio that you are using by entering er_print -V. You must use a version that is no older then June 2006.


  45. Why do I get an error message saying that -r is not recognized when I run collect -r on?
  46. You are using an older version of Sun Studio that does not support the Thread Analyzer. Check the version of Sun Studio that you are using by entering collect -V. You must use a version that is no older then June 2006.


  47. How do I report a bug or share my Thread Analyzer experience with others?
  48. The best resource for sharing your feedback with the Thread Analyzer engineers and users is by reading and posting to the Sun Studio Tools Forum. You may find that your question has already been answered.

(Page last updated February 23, 2007)