<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:richard-llvm@metafoo.co.uk" title="Richard Smith <richard-llvm@metafoo.co.uk>"> <span class="fn">Richard Smith</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - Crashing on pthread_join"
   href="http://llvm.org/bugs/show_bug.cgi?id=20003">bug 20003</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>NEW
           </td>
           <td>RESOLVED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">CC</td>
           <td>
                
           </td>
           <td>richard-llvm@metafoo.co.uk
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>---
           </td>
           <td>INVALID
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - Crashing on pthread_join"
   href="http://llvm.org/bugs/show_bug.cgi?id=20003#c1">Comment # 1</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - Crashing on pthread_join"
   href="http://llvm.org/bugs/show_bug.cgi?id=20003">bug 20003</a>
              from <span class="vcard"><a class="email" href="mailto:richard-llvm@metafoo.co.uk" title="Richard Smith <richard-llvm@metafoo.co.uk>"> <span class="fn">Richard Smith</span></a>
</span></b>
        <pre>Your code has a data race. Building with -fsanitize=thread gives this:


WARNING: ThreadSanitizer: data race (pid=24036)
  Read of size 8 at 0x7d080000efc0 by main thread:
    #0 printMatrix <null>:0 (a.out+0x00000009f486)
    #1 main <null>:0 (a.out+0x0000000a056d)

  Previous write of size 8 at 0x7d080000efc0 by thread T1:
    #0 multMatrix <null>:0 (a.out+0x00000009e499)
    #1 multMatrixThread <null>:0 (a.out+0x00000009e881)

  As if synchronized via sleep:
    #0 sleep
/usr/local/google/home/richardsmith/build/llvm-3/src/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:243
(a.out+0x000000035d20)
    #1 main <null>:0 (a.out+0x0000000a0366)

  Location is heap block of size 32 at 0x7d080000efc0 allocated by main thread:
    #0 malloc
/usr/local/google/home/richardsmith/build/llvm-3/src/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:460
(a.out+0x0000000370ad)
    #1 allocMatrix <null>:0 (a.out+0x00000009dcf1)
    #2 main <null>:0 (a.out+0x00000009fac7)

  Thread T1 (tid=24039, finished) created by main thread at:
    #0 pthread_create
/usr/local/google/home/richardsmith/build/llvm-3/src/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:842
(a.out+0x00000003ac6f)
    #1 main <null>:0 (a.out+0x0000000a02fa)

SUMMARY: ThreadSanitizer: data race ??:0 printMatrix


Note that you increment 'i' at the wrong place in your loop, so you never
actually join the thread you created. Fixing that bug removes the data race and
makes your code work.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>