Closed Bug 345709 Opened 20 years ago Closed 20 years ago

A better fix for bug 291702 (crash when flex is summing up to zero) is needed

Categories

(Core :: Layout, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9alpha1

People

(Reporter: martijn.martijn, Assigned: bzbarsky)

References

Details

(Keywords: fixed1.8.1)

Attachments

(3 files)

The fix for bug 291702 is not good, although it fixes the crash in that bug. See bug 291702, comment 16: " I'm still not sure what the check against nscoord_MAX is doing.... sr=bzbarsky, but what we should _really_ do, imo is: 1) Not parse negative flex values in CSS (use ParsePositiveVariant instead of ParseVariant). 2) Not allow negative values from attributes. 3) Deal with some of flexes overflow somehow (perhaps the nscoord_MAX check here does that?) "
Attached file testcase —
Arghh! I was too quick with checking in the patch from bug 291702. It doesn't protect agains this testcase, so it's clearly not the right patch.
Attached patch patch — — Splinter Review
Well, this makes it not crash, but I don't think that's the good way of dealing with it, is it?
I'd say we want to treat flexes that add up to 0 due to overflow as not being set at all, preferably... Alternately, we could only apply flexes up to the point when we'd overflow, then nothing. Neil, thoughts? Realistically, pretty much any non-crashing behavior for that testcase would be good.
Well, i'd prefer for nscoord to be float. In the interim, assuming not too many call sites are involved, should we change flex from an nscoord to a float? Failing that, is there any way we can limit the flex to something reasonable - as 0xFFFF isn't, how about 0xFFFFFFFF / GetChildCount() ?
If it's an nscoord it should be nscoord_MAX / GetChildCount(). When nscoord becomes a float, this will just be a Very Big Number.
I'm afraid I don't have time nor the knowledge to make a better patch, atm. Fwiw, the patch seems to fix the crash and doesn't seem to regress anything, afaics.
Attachment #231194 - Flags: review?(neil)
Comment on attachment 231194 [details] [diff] [review] Neil, something like this? I was trying to work out whether floats make our life easier but in fact they make it harder as we assume we can exactly add and subtract flexes.
Attachment #231194 - Flags: review?(neil) → review+
Attachment #231194 - Flags: superreview?(roc)
Attachment #231194 - Flags: superreview?(roc) → superreview+
Fixed for 1.9a.
Assignee: nobody → bzbarsky
Target Milestone: --- → mozilla1.9alpha
Status: NEW → RESOLVED
Closed: 20 years ago
OS: Windows XP → All
Hardware: PC → All
Resolution: --- → FIXED
would be nice to see this in 1.8.1-branch, the testcase crashes branch hard.
Comment on attachment 231194 [details] [diff] [review] Neil, something like this? Yeah, might not be a bad idea.
Attachment #231194 - Flags: approval1.8.1?
Comment on attachment 231194 [details] [diff] [review] Neil, something like this? a=beltzner on behalf of drivers for the mozilla_1_8_branch
Attachment #231194 - Flags: approval1.8.1? → approval1.8.1+
Fixed on 1.8.1 branch.
Keywords: fixed1.8.1
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: