<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><span class="vcard"><a class="email" href="mailto:dblaikie@gmail.com" title="David Blaikie <dblaikie@gmail.com>"> <span class="fn">David Blaikie</span></a>
</span> changed
          <a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED - llvm-cov: wrong code coverage for statements before fork()"
   href="https://bugs.llvm.org/show_bug.cgi?id=48264">bug 48264</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;">Resolution</td>
           <td>INVALID
           </td>
           <td>---
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>RESOLVED
           </td>
           <td>REOPENED
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED - llvm-cov: wrong code coverage for statements before fork()"
   href="https://bugs.llvm.org/show_bug.cgi?id=48264#c5">Comment # 5</a>
              on <a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED - llvm-cov: wrong code coverage for statements before fork()"
   href="https://bugs.llvm.org/show_bug.cgi?id=48264">bug 48264</a>
              from <span class="vcard"><a class="email" href="mailto:dblaikie@gmail.com" title="David Blaikie <dblaikie@gmail.com>"> <span class="fn">David Blaikie</span></a>
</span></b>
        <pre>(In reply to Yibiao Yang from <a href="show_bug.cgi?id=48264#c4">comment #4</a>)
<span class="quote">> (In reply to David Blaikie from <a href="show_bug.cgi?id=48264#c3">comment #3</a>)
> > (In reply to Yibiao Yang from <a href="show_bug.cgi?id=48264#c2">comment #2</a>)
> > > (In reply to David Blaikie from <a href="show_bug.cgi?id=48264#c1">comment #1</a>)
> > > > That sounds correct to me - the program forked, so two processes reached
> > > > those two lines. lldb probably only follows one of those processes.
> > > > 
> > > > Try adding a printf/output between line 9 and 10, and you'll see it prints
> > > > out twice.
> > > 
> > > Thank you very much. Yes, it is indeed fork. So there is no problem as Line
> > > 9 and Line 10 are marked as executed twice. 
> > > 
> > > But for Line 3 and Line 4, I was wondering that they should marked as only
> > > executed once since calling to fork is at Line 9. Only at that time, there
> > > are two processes.
> > 
> > That's how fork works - a single process runs until fork is called, then
> > that process is cloned into two that continue from the fork call.
> > <a href="https://man7.org/linux/man-pages/man2/fork.2.html">https://man7.org/linux/man-pages/man2/fork.2.html</a>

> From this point of view, it also make sense as these two lines are marked as
> executed twice. Gcov behaves differently. I think both are correct. Thank
> you very much.</span >

Sorry, misunderstood your comment and I didn't look at the text closely.

Yeah, it is noteworthy that the early statements show as executed twice - when
they certainly were not. (the fork only executes statements after it twice).
I'd guess LLVM kept the counts in memory/registers that were duplicated when
the process forked, then both sets of values were added to the counts.

That does seem questionable, and gcc/gcov seems more accurate here.</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>