Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Eric's list of four issues is pretty much spot on. But debugging these issues is tough.</p> <p>For deadlock, I've always favored "leveled locks". Essentially you give each type of lock a level number. And then require that a thread aquire locks that are monotonic.</p> <p>To do leveled locks, you can declare a structure like this:</p> <pre><code>typedef struct { os_mutex actual_lock; int level; my_lock *prev_lock_in_thread; } my_lock_struct; static __tls my_lock_struct *last_lock_in_thread; void my_lock_aquire(int level, *my_lock_struct lock) { if (last_lock_in_thread != NULL) assert(last_lock_in_thread-&gt;level &lt; level) os_lock_acquire(lock-&gt;actual_lock) lock-&gt;level = level lock-&gt;prev_lock_in_thread = last_lock_in_thread last_lock_in_thread = lock } </code></pre> <p>What's cool about leveled locks is the possibility of deadlock causes an assertion. And with some extra magic with <strong>FUNC</strong> and <strong>LINE</strong> you know exactly what badness your thread did.</p> <p>For data races and lack of synchronization, the current situation is pretty poor. There are static tools that try to identify issues. But false positives are high.</p> <p>The company I work for ( <a href="http://www.corensic.com" rel="nofollow noreferrer">http://www.corensic.com</a> ) has a new product called Jinx that actively looks for cases where race conditions can be exposed. This is done by using virtualization technology to control the interleaving of threads on the various CPUs and zooming in on communication between CPUs.</p> <p>Check it out. You probably have a few more days to download the Beta for free.</p> <p>Jinx is particularly good at finding bugs in lock free data structures. It also does very well at finding other race conditions. What's cool is that there are no false positives. If your code testing gets close to a race condition, Jinx helps the code go down the bad path. But if the bad path doesn't exist, you won't be given false warnings.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload