This is an archive of the discontinued LLVM Phabricator instance.

Fix integer overflow in ConcurrentHashtTableByPtr
ClosedPublic

Authored by andrew.w.kaylor on Aug 16 2023, 2:12 PM.

Details

Summary

This fixes a problem with potential integer overflow when multiplying two 32-bit values and assigning the result to a 64-bit value.

The potential overflow has been present since D132455 was re-landed. The initial version of the patch defined MaxBucketSize and NumberOfBuckets as size_t (which I guess would still be a problem for some targets). When the patch was re-landed they were defined as uint32_t, making the calculation of ExtHashMask subject to overflow.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptAug 16 2023, 2:12 PM
andrew.w.kaylor requested review of this revision.Aug 16 2023, 2:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 16 2023, 2:12 PM
MaskRay accepted this revision.Aug 16 2023, 2:22 PM
MaskRay added a subscriber: MaskRay.

While here, remove the parens as Multiplication having precedence over addition is well-known.

This revision is now accepted and ready to land.Aug 16 2023, 2:22 PM
This revision was landed with ongoing or failed builds.Aug 16 2023, 3:43 PM
This revision was automatically updated to reflect the committed changes.