This is an archive of the discontinued LLVM Phabricator instance.

[Sample Profile Reader] Fix potential integer overflow/infinite loop bug in sample profile reader
ClosedPublic

Authored by huangjd on Aug 23 2022, 12:08 PM.

Details

Summary

Change loop induction variable type to match the type of "SIZE" where it's compared against, to prevent infinite loop caused by overflow wraparound if there are more than 2^32 samples

Diff Detail

Event Timeline

huangjd created this revision.Aug 23 2022, 12:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2022, 12:08 PM
huangjd requested review of this revision.Aug 23 2022, 12:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2022, 12:08 PM
wenlei accepted this revision.Aug 23 2022, 12:35 PM

The change makes sense since the fields are actually 64-bit ones. But which one of the loops did you run into issue with? Curious which part is overflowing int32.

This revision is now accepted and ready to land.Aug 23 2022, 12:35 PM

It is more of a precaution, but I did come across very large afdo profiles.

This revision was landed with ongoing or failed builds.Aug 23 2022, 1:36 PM
This revision was automatically updated to reflect the committed changes.