Closed Bug 1447405 Opened 6 years ago Closed 6 years ago

Valgrind cries at nsFrame::ComputeSize in stylo-only builds.

Categories

(Core :: Layout, defect, P3)

defect

Tracking

()

RESOLVED FIXED

People

(Reporter: emilio, Assigned: jseward)

References

Details

Attachments

(2 files)

It's likely a false positive from the unconditional branches that get removed (it's likely to be optimized differently).

I'm going to land an expectation change pending further investigation sin Julian told me that he was working on updating Valgrind in the tree to catch more cases like these.
Assignee: nobody → emilio
Attachment #8960723 - Flags: review?(jseward)
Assignee: emilio → nobody
Pushed by ecoal95@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/e289c669eea2
Add a valgrind suppression on a CLOSED TREE. rpending=jseward
Comment on attachment 8960723 [details] [diff] [review]
Patch for the suppression.

Per IRC discussion this was indeed a false-positive, but the better fix is to initialize the relevant boolean in nsFrame::ComputeSize. Julian said he was looking into it.
Attachment #8960723 - Flags: review?(jseward)
I believe this is happening because, in nsFrame::ComputeSize(), at the
following two places

5731
  if (maxISizeCoord.GetUnit() != eStyleUnit_None &&
      !(isFlexItem && usingFlexBasisForISize)) {

5742
  if (minISizeCoord.GetUnit() != eStyleUnit_Auto &&
      !(isFlexItem && usingFlexBasisForISize)) {

the subterm

  (isFlexItem && usingFlexBasisForISize)

is compiled as

  (usingFlexBasisForISize && isFlexItem)

This is correct (ignoring the performance effects) because the compiler can
see that isFlexItem is false when usingFlexBasisForISize is undefined.  The
code preceding the conditionals has the structure

  bool isFlexItem = parentFrame && parentFrame->IsFlexContainerFrame() &&
    !parentFrame->HasAnyStateBits(NS_STATE_FLEX_IS_EMULATING_LEGACY_BOX) &&
    !HasAnyStateBits(NS_FRAME_OUT_OF_FLOW);
  ..
  bool usingFlexBasisForISize;
  if (isFlexItem) {
    ..
    usingFlexBasisForISize =
      (flexContainerIsRowOriented == inlineAxisSameAsParent);    
    ..
  }

So after this point, either
  isFlexItem is true and usingFlexBasisForISize is defined
or
  isFlexItem is false and usingFlexBasisForISize is undefined.

Unfortunately the transformation causes a false warning from Memcheck,
because it assumes that every conditional branch in a program is
"important".

A simple "fix" is to initialise usingFlexBasisForISize to false so as to
keep Valgrind happy.  We've added similar initialisations in Gecko a few
times in the past.
A simple fix.
Attachment #8960909 - Flags: review?(emilio)
Comment on attachment 8960909 [details] [diff] [review]
bug1447405-nsFrame-inits-1.diff

Review of attachment 8960909 [details] [diff] [review]:
-----------------------------------------------------------------

r=me, with the valgrind suppression removed from the tree too.

Thanks for looking into this!
Attachment #8960909 - Flags: review?(emilio) → review+
Pushed by jseward@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/ed12db196ee9
Valgrind cries at nsFrame::ComputeSize in stylo-only builds.  r=emilio.
[Triage 2018/03/23 - P3]
Priority: -- → P3
Can this be closed now?
Flags: needinfo?(nerli)
Yeah, probably.
Status: NEW → RESOLVED
Closed: 6 years ago
Flags: needinfo?(nerli)
Keywords: leave-open
Resolution: --- → FIXED
Assignee: nobody → jseward
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: