mirror of
https://github.com/intel/llvm.git
synced 2026-01-25 09:57:08 +08:00
[lldb] Handle a byte size of zero in CompilerType::GetValueAsScalar (#123107)
A bit or byte size of 0 is not a bug. It can legitimately (and frequently) happen in Swift and C, just not in C++. However, it doesn't make sense to read a scalar of zero bytes. Currently, when this happens, we trigger an `lldb_assert` in the data extractor and return 0, which isn't accurate. I have a bunch of reports of the assert triggering, but nobody has been able to provide me with a reproducer that I can turn into a test and I wasn't able to concoct a test case by reverse-engineering the code. rdar://141630334
This commit is contained in:
committed by
GitHub
parent
60e4d24963
commit
8965dd40c6
@@ -1105,8 +1105,11 @@ bool CompilerType::GetValueAsScalar(const lldb_private::DataExtractor &data,
|
||||
return false;
|
||||
|
||||
std::optional<uint64_t> byte_size = GetByteSize(exe_scope);
|
||||
if (!byte_size)
|
||||
// A bit or byte size of 0 is not a bug, but it doesn't make sense to read a
|
||||
// scalar of zero size.
|
||||
if (!byte_size || *byte_size == 0)
|
||||
return false;
|
||||
|
||||
lldb::offset_t offset = data_byte_offset;
|
||||
switch (encoding) {
|
||||
case lldb::eEncodingInvalid:
|
||||
|
||||
Reference in New Issue
Block a user