Closed Bug 1122375 Opened 6 years ago Closed 6 years ago

Fixes to avoid Valgrind false positives with gcc-4.9.x -O2 builds

Categories

(Core :: General, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla38

People

(Reporter: jseward, Assigned: jseward)

Details

Attachments

(4 files)

gcc-4.9.x on x86_64 (at least, maybe other targets) performs apparently
new optimisations at -O2 that confuse Valgrind/Memcheck's uninitialised
value tracking instrumentation and result in false error reports.  As far
as I can tell, this only happens in two places in the tree.  On examination
of the machine code, in both cases the nature of the transformation makes
it difficult and/or a big performance hit to fix Valgrind, so a preferable
approach is to provide minimal dummy initialisations.
In the first of the two problems, in layout/base/nsDisplayList.cpp,
gcc-4.9 appears to transform

  if (e1 && e2) ...

into

  if (e2 && e1) ...

in the case where it can show that e1 is |false| whenever |e2| is
undefined.  This causes Memcheck to complain because it has the
(deeply wired in) assumption that every conditional branch is
important and therefore must be based on defined values.
In the second of the two problems, in layout/style/nsStyleContext.cpp,
gcc-4.9 produces code which is pretty gnarly to say the least, but afaics
depends on the observation that

   undefined-value < 0    is   defined

in the case where the comparison is unsigned, since the result will
always be |false|.
Comment on attachment 8550112 [details] [diff] [review]
Proposed fix for the problem in comment 4

Ugh.

I guess so.


But put a space after all the ","s.
Attachment #8550112 - Flags: review?(dbaron) → review+
https://hg.mozilla.org/mozilla-central/rev/59dec5ab3a40
https://hg.mozilla.org/mozilla-central/rev/170aee1be0dd
Assignee: nobody → jseward
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
You need to log in before you can comment on or make changes to this bug.