Bug 104654 - [CoordinatedGraphics] Use unsigned integers for UpdateAtlas IDs
Summary: [CoordinatedGraphics] Use unsigned integers for UpdateAtlas IDs
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords:
Depends on: 103816
Blocks:
  Show dependency treegraph
 
Reported: 2012-12-11 02:57 PST by Chris Dumez
Modified: 2012-12-11 04:55 PST (History)
5 users (show)

See Also:


Attachments
Patch (16.00 KB, patch)
2012-12-11 03:03 PST, Chris Dumez
kenneth: review+
Details | Formatted Diff | Diff
Patch for landing (16.09 KB, patch)
2012-12-11 04:28 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2012-12-11 02:57:16 PST
UpdateAtlas currently uses *signed* integer type for its identifier. Due to the way we generate those IDs, it would be safer to use *unsigned* integers. This is because the generated ID will overflow at some point and the C and C++ language standards say that overflow of a signed value is undefined behaviour. 

In the C99 standard this is in section 6.5. In the C++98 standard it is in section 5 [expr], paragraph 5. "This means that a correct C/C++ program must never generate signed overflow when computing an expression. It also means that a compiler may assume that a program will never generated signed overflow".

Note that gcc has -fwrapv flag to assume that signed arithmetic overflow of addition, subtraction and multiplication wraps around using twos-complement representation. However, I still believe it is safer and more consistent to use unsigned integers here.
Comment 1 Chris Dumez 2012-12-11 03:03:14 PST
Created attachment 178761 [details]
Patch
Comment 2 Kenneth Rohde Christiansen 2012-12-11 04:04:37 PST
Comment on attachment 178761 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=178761&action=review

> Source/WebKit2/ChangeLog:14
> +        This patch uses unsigned integer type for UpdateAtlas IDs.

does unsigned have defined behavior?
Comment 3 Chris Dumez 2012-12-11 04:15:11 PST
(In reply to comment #2)
> (From update of attachment 178761 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=178761&action=review
> 
> > Source/WebKit2/ChangeLog:14
> > +        This patch uses unsigned integer type for UpdateAtlas IDs.
> 
> does unsigned have defined behavior?

Yes, unsigned integer types are guaranteed to wrap on overflow in C / C++.
Comment 4 Chris Dumez 2012-12-11 04:28:28 PST
Created attachment 178775 [details]
Patch for landing

Updated the Changelog to clarify the behavior for unsigned integers on overflow.
Comment 5 WebKit Review Bot 2012-12-11 04:54:55 PST
Comment on attachment 178775 [details]
Patch for landing

Clearing flags on attachment: 178775

Committed r137293: <http://trac.webkit.org/changeset/137293>
Comment 6 WebKit Review Bot 2012-12-11 04:55:00 PST
All reviewed patches have been landed.  Closing bug.