This is an archive of the discontinued LLVM Phabricator instance.

[LLDB][NFC][Reliability] Fixes for int overflow and uninitialized state
ClosedPublic

Authored by fixathon on Jul 29 2022, 12:35 PM.

Details

Summary

Fixing potential int overflow and uninitialized variables.
These were found by Coverity static code inspection.

Diff Detail

Event Timeline

fixathon created this revision.Jul 29 2022, 12:35 PM
Herald added a project: Restricted Project. · View Herald Transcript
fixathon requested review of this revision.Jul 29 2022, 12:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 29 2022, 12:35 PM
clayborg accepted this revision.Jul 29 2022, 1:29 PM
This revision is now accepted and ready to land.Jul 29 2022, 1:29 PM
shafik added inline comments.Jul 29 2022, 8:10 PM
lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.cpp
67

So we know that wp_index is never greater than 11?

77

You did not update 0xF to 0xFULL like you did the constants above. Was that on purpose?

fixathon marked 2 inline comments as done.Jul 30 2022, 12:42 AM
fixathon added inline comments.
lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.cpp
67

For this platform, based on the code and the hardcoded constant the range of wp_index is limited to 0-3 (inclusive)

77

Not on purpose. It's interesting this instance wasn't flagged by coverity likely because
max wp_index value is 3 and 0xF << 28 is still within the 32-bit limit of sizeof(int) the default type for 0xF literal. Then, the signed int will get converted to uint64_t for the bitwise-OR. It's a bit iffy due to the signed type, but should work.

Agreed it would be best be explicit and consistent and mark it as 0xFull. I could include this it into the next batch of reliability diffs next week.