[llvm-bugs] [Bug 48264] llvm-cov: wrong code coverage for statements before fork()
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Dec 16 23:16:08 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=48264
David Blaikie <dblaikie at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|INVALID |---
Status|RESOLVED |REOPENED
--- Comment #5 from David Blaikie <dblaikie at gmail.com> ---
(In reply to Yibiao Yang from comment #4)
> (In reply to David Blaikie from comment #3)
> > (In reply to Yibiao Yang from comment #2)
> > > (In reply to David Blaikie from comment #1)
> > > > 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.
> > https://man7.org/linux/man-pages/man2/fork.2.html
>
> 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.
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201217/505b381f/attachment.html>
More information about the llvm-bugs
mailing list