<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/98315>98315</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
LLDB aborted while examining a structure variable: "lldb: /llvm-project/lldb/source/Expression/DWARFExpression.cpp:2192: static bool lldb_private::DWARFExpression::Evaluate(lldb_private::ExecutionContext*, lldb_private::RegisterContext*, lldb::ModuleSP, const lldb_private::DataExtractor&, const lldb_private::plugin::dwarf::DWARFUnit*, lldb::RegisterKind, const lldb_private::Value*, const lldb_private::Value*, lldb_private::Value&, lldb_private::Status*): Assertion `ap_int.getBitWidth() >= bit_size' failed."
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
edumoot
</td>
</tr>
</table>
<pre>
1. In LLVM 18.1.8, LLDB aborted while executing `print` or `fr v` command on line 16 of the binary generated with `-g -O3`,
```
clang -g -O3 320.c -o 320.out
lldb 320.out
(lldb) b 320.c:16
Breakpoint 1: where = 320.out`main [inlined] func_1 at 320.c:16:25, address = 0x0000000000001130
(lldb) r
[...]
* thread #1, name = '320.out', stop reason = breakpoint 1.1
frame #0: 0x0000555555555130 320.out`main [inlined] func_1 at 320.c:16:25
13 struct S0 **l_2 = &l_3[2];
14 int i;
15 (*l_2) = (void*)0;
-> 16 return g_4[2][3][0].f0;
17 }
18
19 int main (int argc, char* argv[])
(lldb) p l_3
lldb: /llvm-project/lldb/source/Expression/DWARFExpression.cpp:2192: static bool lldb_private::DWARFExpression::Evaluate(lldb_private::ExecutionContext*, lldb_private::RegisterContext*, lldb::ModuleSP, const lldb_private::DataExtractor&, const lldb_private::plugin::dwarf::DWARFUnit*, lldb::RegisterKind, const lldb_private::Value*, const lldb_private::Value*, lldb_private::Value&, lldb_private::Status*): Assertion `ap_int.getBitWidth() >= bit_size' failed.
LLDB diagnostics will be written to /tmp/diagnostics-bd40ff
Please include the directory content when filing a bug report
Aborted (core dumped)
```
and the diagnostics file contains nothing,
```
ls -lt /tmp/diagnostics-bd40ff
total 0
-rw-rw-r-- 1 ad ad 0 Jul 10 13:36 diagnostics.log
```
under the context of llvm 18.1.8.
```
(lldb) version
lldb version 18.1.8 (https://github.com/llvm/llvm-project.git revision 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
clang revision 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff
llvm revision 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff
```
2. The the same problem occurs to the binary produced by `-g -O1` or `-g -O2` in LLVM18.1.8, but it has no such problems to the binary emitted by `-g -O0`.
The C source code lists below.
```
#include <stdint.h>
volatile uint64_t csmith_sink_ = 0;
struct S0 {
volatile uint8_t f0;
};
static struct S0 g_4[8][9][3] = {{{{1UL},{248UL},{7UL}},{{0xA4L},{253UL},{0xD7L}},{{0xD7L},{248UL},{0x8FL}},{{0xEDL},{1UL},{1UL}},{{0UL},{0xDCL},{253UL}},{{0x98L},{0xA4L},{3UL}},{{0x0FL},{0UL},{1UL}},{{1UL},{0UL},{0x73L}},{{0x57L},{1UL},{0x73L}}},{{{0x02L},{0UL},{1UL}},{{0xDCL},{255UL},{3UL}},{{253UL},{0x8FL},{253UL}},{{0UL},{0UL},{1UL}},{{0x73L},{0x6DL},{0x8FL}},{{255UL},{0xEDL},{0xD7L}},{{0UL},{0UL},{1UL}},{{1UL},{0UL},{0x0FL}},{{0UL},{0x11L},{248UL}}},{{{0UL},{1UL},{0x6DL}},{{0xEDL},{248UL},{0x98L}},{{1UL},{255UL},{255UL}},{{0UL},{0UL},{246UL}},{{255UL},{0UL},{0UL}},{{1UL},{255UL},{0xF8L}},{{0x73L},{248UL},{0x71L}},{{1UL},{1UL},{1UL}},{{0xF8L},{0x11L},{1UL}}},{{{0x66L},{0UL},{1UL}},{{3UL},{0UL},{7UL}},{{0x6DL},{0x66L},{1UL}},{{0xDCL},{255UL},{1UL}},{{255UL},{7UL},{1UL}},{{250UL},{0UL},{0x71L}},{{255UL},{1UL},{0xF8L}},{{0x78L},{0xF8L},{0UL}},{{0x02L},{0x23L},{246UL}}},{{{0x02L},{253UL},{255UL}},{{0x78L},{0xD7L},{0x98L}},{{255UL},{0x6DL},{0x6DL}},{{250UL},{1UL},{248UL}},{{255UL},{0xDCL},{0x0FL}},{{0xDCL},{2UL},{1UL}},{{0x6DL},{0xEDL},{3UL}},{{3UL},{2UL},{0UL}},{{0x66L},{0xDCL},{0x23L}}},{{{0xF8L},{1UL},{0xEDL}},{{1UL},{0x6DL},{255UL}},{{0x73L},{0xD7L},{0UL}},{{1UL},{253UL},{0UL}},{{255UL},{0x23L},{0UL}},{{0UL},{0xF8L},{0UL}},{{1UL},{1UL},{255UL}},{{0xEDL},{0UL},{0xEDL}},{{0UL},{7UL},{0x23L}}},{{{0UL},{255UL},{0UL}},{{1UL},{0x66L},{3UL}},{{0xD7L},{0UL},{1UL}},{{1UL},{0UL},{0x0FL}},{{0UL},{0x11L},{248UL}},{{0UL},{1UL},{0x6DL}},{{0xEDL},{248UL},{0x98L}},{{1UL},{255UL},{255UL}},{{0UL},{0UL},{246UL}}},{{{255UL},{0UL},{0UL}},{{1UL},{255UL},{0xF8L}},{{0x73L},{248UL},{0x71L}},{{1UL},{1UL},{1UL}},{{0xF8L},{0x11L},{1UL}},{{0x66L},{0UL},{1UL}},{{3UL},{0UL},{7UL}},{{0x6DL},{0x66L},{1UL}},{{0xDCL},{255UL},{1UL}}}};
static uint32_t func_1(void)
{
struct S0 *l_3[8] = {(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0};
struct S0 **l_2 = &l_3[2];
int i;
(*l_2) = (void*)0;
return g_4[2][3][0].f0;
}
int main (int argc, char* argv[])
{
func_1();
return 0;
}
```
3. GDB and LLVM16.0.3 work well.
```
gdb 320.out
(gdb) b 320.c:16
Breakpoint 1 at 0x1130: file 320.c, line 16.
(gdb) r
[...]
Breakpoint 1, func_1 () at 320.c:16
16 return g_4[2][3][0].f0;
(gdb) p l_3
$1 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
(gdb) info local
l_3 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
l_2 = <optimised out>
i = <optimised out>
(gdb)
```
```
* thread #1, name = '320.out', stop reason = breakpoint 1.1
frame #0: 0x0000555555555130 320.out`main [inlined] func_1 at 320.c:16:25
13 struct S0 **l_2 = &l_3[2];
14 int i;
15 (*l_2) = (void*)0;
-> 16 return g_4[2][3][0].f0;
17 }
18
19 int main (int argc, char* argv[])
(lldb) fr v
(S0 *[8]) l_3 = {
[0] = NULL
[1] = NULL
[2] = NULL
[3] = NULL
[4] = NULL
[5] = NULL
[6] = NULL
[7] = NULL
}
(lldb) version
lldb version 16.0.3 (https://github.com/llvm/llvm-project.git revision da3cd333bea572fb10470f610a27f22bcb84b08c)
clang revision da3cd333bea572fb10470f610a27f22bcb84b08c
llvm revision da3cd333bea572fb10470f610a27f22bcb84b08c
```
4. In "LLVM17.0.6", it produce a similar error, with a slight difference on the error message.
```
/llvm-project/lldb/source/Expression/DWARFExpression.cpp:2191: static bool lldb_private::DWARFExpression::Evaluate(lldb_private::ExecutionContext*, lldb_private::RegisterContext*, lldb::ModuleSP, const lldb_private::DataExtractor&, const DWARFUnit*, lldb::RegisterKind, const lldb_private::Value*, const lldb_private::Value*, lldb_private::Value&, lldb_private::Status*): Assertion `ap_int.getBitWidth() >= bit_size' failed.
Aborted (core dumped)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsOluT6rjRv0bz0jUuXfCFBx64DF99yWyytSdn95GSbdkox1iULDOc_PqULAM22AxzcirZnOwUxeBWq9X3trvNq0rmpRAz5C-Qv3ritdkqPRNpvVPKPMUq_TojHvx_Ca-vv_4EJPKIFyG6hNfX1QJ4rLQRKbxtZSFAHEVSG1nmgAK817I0KMCgtL3MNBzsVaJ2O16moEooZCmABKAyMFs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