Closed Bug 659989 Opened 13 years ago Closed 13 years ago

Policy overflow with mmgc-demo

Categories

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

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: treilly, Unassigned)

Details

Attachments

(1 file, 1 obsolete file)

Attached patch check for int overflow (obsolete) — Splinter Review
Encountered this in my convoluted demo code:

hg.mozilla.org/users/treilly_adobe.com/mmgc-demo

spot fix patch attached
Attachment #535369 - Attachment is patch: true
The failure here is this (maybe new?) assert:

        GCAssert(minorAllocationBudget > 0);
(I want to look further into this to understand what scenarios we would end up with such an enormous value for A().  But I'm fine with the patch Tom attached, in part because I was peeking over his shoulder when he wrote it.)
Attachment #535369 - Flags: superreview?(lhansen)
Attachment #535369 - Flags: review?(fklockii)
(In reply to comment #2)
> (I want to look further into this to understand what scenarios we would end
> up with such an enormous value for A().  But I'm fine with the patch Tom
> attached, in part because I was peeking over his shoulder when he wrote it.)

On further reflection, I'm not sure we want to do it this way: Do we know that INT_MAX is always 32-bit and not a int64_t?  (Because if it were the max int64_t, then we could fall back into the same problem of making a negative minorAllocationBudget in the int32_t cast.)
Comment on attachment 535369 [details] [diff] [review]
check for int overflow

R- until I'm convinced that INT_MAX is reliably the 32-bit maximum and not the 64-bit one.
Attachment #535369 - Flags: review?(fklockii) → review-
After reading over http://en.wikipedia.org/wiki/Limits.h I'm willing to believe that INT_MAX could be reliable, even though the standard does not dictate that it must be so.

I think I would be satisfied if the patch were extended with:
  STATIC_ASSERT(INT_MAX == int64_t(int32_t(INT_MAX)));
(In reply to comment #4)
> R- until I'm convinced that INT_MAX is reliably the 32-bit maximum and not
> the 64-bit one.

It's not like the maximum for a 32-bit signed integer is gonna vary...

s/INT_MAX/0x7fffffff/
Comment on attachment 535369 [details] [diff] [review]
check for int overflow

Canceling SR until Felix is happy.
Attachment #535369 - Flags: superreview?(lhansen)
Attached patch With safety beltSplinter Review
Attachment #535369 - Attachment is obsolete: true
Attachment #538892 - Flags: superreview?(lhansen)
Attachment #538892 - Flags: review?(fklockii)
Comment on attachment 538892 [details] [diff] [review]
With safety belt

count me satisfied!
Attachment #538892 - Flags: review?(fklockii) → review+
Attachment #538892 - Flags: superreview?(lhansen) → superreview+
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
changeset: 6428:f73c7c31ab1b
user:      Tommy Reilly <treilly@adobe.com>
summary:   Bug 659989 - Fix policy overflow on double to int conversion, clamp to MAX_INT (r=fklockii,sr=lhansen)

http://hg.mozilla.org/tamarin-redux/rev/f73c7c31ab1b
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: