Closed
Bug 118117
Opened 23 years ago
Closed 21 years ago
Improper single precision constants in nsUnitConversion.h
Categories
(Core :: Layout, defect, P1)
Tracking
()
RESOLVED
FIXED
People
(Reporter: tenthumbs, Assigned: roc)
References
Details
Attachments
(2 files, 1 obsolete file)
1.32 KB,
patch
|
roc
:
review+
roc
:
superreview+
|
Details | Diff | Splinter Review |
962 bytes,
patch
|
roc
:
review+
bzbarsky
:
superreview+
|
Details | Diff | Splinter Review |
Look at the definitions of CEIL_CONST_FLOAT and
ROUND_EXCLUSIVE_CONST_FLOAT in mozilla/xpcom/ds/nsUnitConversion.h. The
constants are too precise for single precision IEEE floating point. On
Linux, gcc quietly converts them to the nearest single precision value
which are 1.0 and 0.5 respectively. This breaks the functions that use
these constants.
The comments in the code indicate the author knew something could go
wrong and it has. On Linux, it should really be something like
#define CEIL_CONST_FLOAT (1.0f - FLT_EPSILON)
#define ROUND_EXCLUSIVE_CONST_FLOAT (0.5f*CEIL_CONST_FLOAT)
That should probably work for ANSI compilers but I'm sure there's some
exception out there.
Because this affects all sorts of things, I'm setting the severity to
critical.
We're subtracting, not adding, so it should be
#define CEIL_CONST_FLOAT (1.0f - 0.5f*FLT_EPSILON)
Comment 2•23 years ago
|
||
blames to peterl. not sure if he actually added these constants.
Assignee: dougt → peterl
Comment 3•23 years ago
|
||
These belong to the peterl before me, --->back to XPCOM
Note: I'm "peterlubczynski" in CVS.
Assignee: peterl → dougt
Comment 4•23 years ago
|
||
Over to LAYOUT. This header does not belong in XPCOM.
Assignee: dougt → attinasi
Component: XPCOM → Layout
QA Contact: scc → petersen
Updated•23 years ago
|
Target Milestone: --- → mozilla1.1
Comment 5•23 years ago
|
||
tenthumbs, if you have a proposed for this bug, can you attach a patch? Thanks.
SInce I can't test all compilers I can't provide a patch. However, for
gcc on Linux (and presumably other gcc's) you change the two defines
taht are marked as suspect to something like this:
#define CEIL_CONST_FLOAT (1.0f - 0.5*FLT_EPSILON)
#define ROUND_EXCLUSIVE_CONST_FLOAT (0.5f*CEIL_CONST_FLOAT)
This should work on most reasonable compilers but that's not saying
much. You should also check that the compiler pre-computes these.
Calculating these at run time is a performance loss.
Comment 8•22 years ago
|
||
->Misc Code
Assignee: other → misc
Component: Layout → Layout: Misc Code
QA Contact: ian → nobody
Target Milestone: Future → ---
![]() |
||
Comment 10•21 years ago
|
||
![]() |
||
Comment 11•21 years ago
|
||
Comment on attachment 135586 [details] [diff] [review]
Patch
Thoughts?
Attachment #135586 -
Flags: superreview?(roc)
Attachment #135586 -
Flags: review?(roc)
Assignee | ||
Comment 12•21 years ago
|
||
Comment on attachment 135586 [details] [diff] [review]
Patch
Looks reasonable.
I think any need for these constants indicates a design flaw...
Attachment #135586 -
Flags: superreview?(roc)
Attachment #135586 -
Flags: superreview+
Attachment #135586 -
Flags: review?(roc)
Attachment #135586 -
Flags: review+
![]() |
||
Comment 14•21 years ago
|
||
Checked in.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Reporter | ||
Comment 15•21 years ago
|
||
Reality has kept me away from mozilla for the last few weeks so I'm way behind
in bugs. Sorry for the late response.
Unfortunately, the patch is not correct. Presumably CEIL_CONST_FLOAT is supposed
to be less than but as close to 1.0 as possible. FLT_EPSILON is the smallest
number that can be _added_ to 1.0. Subtraction is different, which I said in
comment 2. I have a demo if anyone doesn't believe me (and they shouldn't).
Reopening with a patch upcoming.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Reporter | ||
Comment 16•21 years ago
|
||
Reporter | ||
Comment 18•21 years ago
|
||
Assigning bugs to me is a sure way top make them disappear, but ....
This should do it. Use a real value for FLT_EPSILON not a made-up one jsut in
case. I could be convinced that it might be better to error out if FLT_EPSILON
isn't defined.
Attachment #136012 -
Attachment is obsolete: true
Attachment #137751 -
Flags: superreview?(bz-vacation)
Attachment #137751 -
Flags: review?(roc)
Reporter | ||
Comment 19•21 years ago
|
||
Oh yeah, someone will have to check this in for me.
![]() |
||
Comment 20•21 years ago
|
||
Comment on attachment 137751 [details] [diff] [review]
the right fix
sr=bzbarsky (I also can't check this in, so someone else would need to do it).
Attachment #137751 -
Flags: superreview?(bz-vacation) → superreview+
Assignee | ||
Comment 21•21 years ago
|
||
Comment on attachment 137751 [details] [diff] [review]
the right fix
I'll check in
Attachment #137751 -
Flags: review?(roc) → review+
Assignee | ||
Comment 22•21 years ago
|
||
Assigning to myself for checkin
Assignee: tenthumbs → roc
Priority: -- → P1
Assignee | ||
Comment 23•21 years ago
|
||
Fix checked in.
Status: NEW → RESOLVED
Closed: 21 years ago → 21 years ago
Resolution: --- → FIXED
![]() |
||
Comment 24•21 years ago
|
||
*** Bug 120690 has been marked as a duplicate of this bug. ***
Updated•7 years ago
|
Product: Core → Core Graveyard
Updated•7 years ago
|
Component: Layout: Misc Code → Layout
Product: Core Graveyard → Core
You need to log in
before you can comment on or make changes to this bug.
Description
•