Closed Bug 485967 Opened 16 years ago Closed 16 years ago

Fix numeric overflow in GetPerformanceCounter for UNIX

Categories

(Tamarin Graveyard :: Garbage Collection (mmGC), defect)

defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: rishah, Unassigned)

References

Details

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.7) Gecko/2009021906 Firefox/3.0.7 Build Identifier: In GC::GetPerformanceCounter() for UNIX there is an overflow bug in following line of code uint64_t seconds = (uint64_t)(tv.tv_sec * 1000000); The cast to uint64_t should be applied to tv.tv_sec prior to mutiplying Reproducible: Always
Blocks: 481683
Attached patch [v1] patch (deleted) — Splinter Review
Attachment #370239 - Flags: review?(treilly)
Attachment #370239 - Flags: review?(lhansen)
Comment on attachment 370239 [details] [diff] [review] [v1] patch I don't understand the bug or why this fixes it, shouldn't the original code promote the value to 64 bits first then do the multiply?
In the original code the multiplication happens first resulting in the overflow since tv.tv_sec is "long" and then it gets converted to uint64_t. The fix forces "long" to get converted to uint64_t and then undergo multiplication.
Oh I got it, the fix is to remove the parens, I was reading the diff backwards.
Attachment #370239 - Flags: review?(treilly) → review+
Attachment #370239 - Flags: review?(lhansen) → review+
Fixed changeset: 1689:1fd54b08b399
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: