[Lldb-commits] [PATCH] D146919: Fix Issue #61706
LU Hongyi via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Sun Mar 26 09:21:49 PDT 2023
jwnhy created this revision.
jwnhy added reviewers: clayborg, jingham.
Herald added a project: All.
jwnhy requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
As described in #61706 <https://github.com/llvm/llvm-project/issues/61706>, the `ValueObjectChild::UpdateValue(...)` may underflow the unsigned `m_bitfield_bit_offset`.
This is due to that in `ValueObjectChild::UpdateValue(...)`, the moved `overhang_bytes` only considers the `bitfield_end - *type_bit_size`. However, under certain cases, the `m_bitfield_bit_offset` may not strictly aligned to `*type_bit_size`, e.g. 27 < 32.
This results 27 - 32 = -5 underflows the unsigned `uint8_t m_bitfield_bit_offset`.
This patch fixes this issue by setting the `overhang_bytes` to the smaller value between `bitfield_end - *type_bit_size` and `m_bitfield_bit_offset` to avoid underflow.
I am quite new to this community, any helps/guidance are much appreciated.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D146919
Files:
lldb/source/Core/ValueObjectChild.cpp
Index: lldb/source/Core/ValueObjectChild.cpp
===================================================================
--- lldb/source/Core/ValueObjectChild.cpp
+++ lldb/source/Core/ValueObjectChild.cpp
@@ -170,6 +170,8 @@
if (bitfield_end > *type_bit_size) {
uint64_t overhang_bytes =
(bitfield_end - *type_bit_size + 7) / 8;
+ if (overhang_bytes > m_bitfield_bit_offset / 8)
+ overhang_bytes = m_bitfield_bit_offset / 8;
m_byte_offset += overhang_bytes;
m_bitfield_bit_offset -= overhang_bytes * 8;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146919.508426.patch
Type: text/x-patch
Size: 631 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230326/660df479/attachment.bin>
More information about the lldb-commits
mailing list