This is an archive of the discontinued LLVM Phabricator instance.

Fix lldb-vscode frame id integer overflow
ClosedPublic

Authored by yinghuitan on Jul 26 2023, 2:53 PM.

Details

Summary

This patch fixes a 32bit integer overflow in lldb-vscode.
The current implementation of frame_id does (thread_index << 19 | frame_index). Since thread_index is a 32 bit integer this leaves only 32 - 19 == 13 bits available for the thread_index. As a result, lldb-vscode can only handle 2^13 == 8192 threads. Normally, this would be sufficient, but we have seen crazy process having +12000 threads, causing the frame_id algorithm above to integer overflow during casting.

The patch fixes the overflow by up casting to 64 bit integer first before bit shifiting.

Diff Detail

Event Timeline

yinghuitan created this revision.Jul 26 2023, 2:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 26 2023, 2:53 PM
yinghuitan requested review of this revision.Jul 26 2023, 2:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 26 2023, 2:53 PM
clayborg accepted this revision.Jul 26 2023, 4:05 PM

We ran into this with a process that had many threads. No easy way to test this without creating a process with 8K threads.

This revision is now accepted and ready to land.Jul 26 2023, 4:05 PM
This revision was automatically updated to reflect the committed changes.