https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/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 >From f83e29d9b6fc747584485bae3f519dcd34a5bb0b Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere <jo...@devlieghere.com> Date: Wed, 15 Jan 2025 10:42:35 -0800 Subject: [PATCH] [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 --- lldb/source/Symbol/CompilerType.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp index e9e6e3bf2600ce..3c4390b89a125a 100644 --- a/lldb/source/Symbol/CompilerType.cpp +++ b/lldb/source/Symbol/CompilerType.cpp @@ -1105,7 +1105,7 @@ bool CompilerType::GetValueAsScalar(const lldb_private::DataExtractor &data, return false; std::optional<uint64_t> byte_size = GetByteSize(exe_scope); - if (!byte_size) + if (!byte_size || *byte_size == 0) return false; lldb::offset_t offset = data_byte_offset; switch (encoding) { _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits