Skip to content

Commit f83e29d

Browse files
committed
[lldb] Handle a byte size of zero in CompilerType::GetValueAsScalar
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 only a bunch of reports of the lldb_assert triggering but no actual example that I could turn into a test. rdar://141630334
1 parent 99ab848 commit f83e29d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lldb/source/Symbol/CompilerType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ bool CompilerType::GetValueAsScalar(const lldb_private::DataExtractor &data,
11051105
return false;
11061106

11071107
std::optional<uint64_t> byte_size = GetByteSize(exe_scope);
1108-
if (!byte_size)
1108+
if (!byte_size || *byte_size == 0)
11091109
return false;
11101110
lldb::offset_t offset = data_byte_offset;
11111111
switch (encoding) {

0 commit comments

Comments
 (0)