Page MenuHomePhabricator

Fix some range issues and 32-bit issues with avatar generation
ClosedPublic

Authored by epriestley on Mar 23 2017, 5:48 PM.
Tags
None
Referenced Files
F14407386: D17543.diff
Tue, Dec 24, 2:50 AM
Unknown Object (File)
Mon, Dec 9, 2:10 PM
Unknown Object (File)
Mon, Dec 9, 12:43 PM
Unknown Object (File)
Mon, Dec 9, 12:43 PM
Unknown Object (File)
Mon, Dec 9, 12:43 PM
Unknown Object (File)
Mon, Dec 9, 12:42 PM
Unknown Object (File)
Mon, Dec 9, 11:17 AM
Unknown Object (File)
Tue, Dec 3, 8:53 AM
Subscribers
None

Details

Summary

Ref T12444. A few issues:

  • x % (y - z) doesn't generate values in the full range: the largest value is never generated. Instead, use x % (1 + y - z).
  • digestToRange(1, count) never generates 0. After fixing the first bug, it could generate count. The range of the arrays is 0..(count-1), inclusive. Generate the correct range instead.
  • unpack('L', ...) can unpack a negative number on a 32-bit system. Use & 0x7FFFFFFF to mask off the sign bit so the result is always a positive integer.
  • FileFinder might return arbitrary keys, but we rely on sequential keys (0, 1, 2, ...)
Test Plan
  • Used bin/people profileimage ... --force to regenerate images.
  • Added some debugging to verify that the math seemed to be working.

Diff Detail

Repository
rP Phabricator
Branch
hashrange
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 16109
Build 21377: Run Core Tests
Build 21376: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Mar 23 2017, 5:50 PM

Like 3/4ths of these were my fault, sorry I am so bad at math.

This revision was automatically updated to reflect the committed changes.