<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/115166>115166</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
LLDB crashed with Assertion failed in function GetMaxU64 of file lldb/source/Utility/DataExtractor.cpp
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
iamanonymouscs
</td>
</tr>
</table>
<pre>
`$ clang --version`
clang version 16.0.0 (https://mirror.nju.edu.cn/git/llvm-project.git 08d094a0e457360ad8b94b017d2dc277e697ca76)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/llvm-08d094a/bin
`$ lldb --version`
lldb version 16.0.0 (https://mirror.nju.edu.cn/git/llvm-project.git revision 08d094a0e457360ad8b94b017d2dc277e697ca76)
clang revision 08d094a0e457360ad8b94b017d2dc277e697ca76
llvm revision 08d094a0e457360ad8b94b017d2dc277e697ca76
`$ cat small.c`
```
#define NITER 4
#define NVARS 20
#define MULTI(X) \
X( 0), X( 1), X( 2), X( 3), X( 4), X( 5), X( 6), X( 7), X( 8), X( 9), \
X(10), X(11), X(12), X(13), X(14), X(15), X(16), X(17), X(18), X(19)
#define DECLAREI(INDEX) inc##INDEX = incs[INDEX]
#define DECLAREF(INDEX) *ptr##INDEX = ptrs[INDEX], result##INDEX = 0
#define LOOP(INDEX) result##INDEX += *ptr##INDEX, ptr##INDEX += inc##INDEX
#define COPYOUT(INDEX) results[INDEX] = result##INDEX
float *ptrs[NVARS];
float results[NVARS];
int incs[NVARS];
void __attribute__((noinline))
foo (int n)
{
int MULTI (DECLAREI);
float MULTI (DECLAREF);
while (n--)
MULTI (LOOP);
MULTI (COPYOUT);
}
float input[NITER * NVARS];
int
main (void)
{
int i;
for (i = 0; i < NVARS; i++)
ptrs[i] = input + i, incs[i] = i;
for (i = 0; i < NITER * NVARS; i++)
input[i] = i;
foo (NITER);
for (i = 0; i < NVARS; i++)
if (results[i] != i * NITER * (NITER + 1) / 2)
return 1;
return 0;
}
```
`$ cat script.py`
```
# cat script.py
import pickle
def fstep(debugger, command, result, internal_dict):
args = command.split()
step = args[0] if args else 'step'
target = debugger.GetSelectedTarget()
process = target.GetProcess()
thread = process.GetSelectedThread()
target_name = target.GetExecutable().GetFilename()
enter_flag = False
while process.is_alive:
frame = thread.GetSelectedFrame()
if frame.IsValid():
module = frame.GetModule()
if module.IsValid():
module_name = module.GetFileSpec().GetFilename()
if target_name != module_name:
if not enter_flag:
enter_flag = True
if step == 'step':
thread.StepOver()
else:
thread.StepInstruction(False)
else:
enter_flag = False
thread.StepOut()
continue
line_entry = frame.GetLineEntry()
if line_entry.IsValid() and line_entry.GetFileSpec().IsValid():
file = line_entry.file.fullpath
line = line_entry.line
column = line_entry.column
address = hex(frame.GetPC())
varvalue = {f"({var.type}){var.name}": var.value for var in frame.GetVariables(True, True, True, True)}
if step == 'step':
thread.StepOver()
else:
thread.StepInstruction(False)
else:
break
```
`$ clang -Og -g small.c`
`$ lldb a.out`
```
(lldb) target create "a.out"
Current executable set to '/home/devil/a.out' (x86_64).
(lldb) command script import script.py
(lldb) command script add -f script.fstep fstep
(lldb) b main
Breakpoint 1: where = a.out`main + 32 at small.c:34:5, address = 0x00000000000016f0
(lldb) run
Process 26967 launched: '/home/devil/a.out' (x86_64)
Process 26967 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x00005555555556f0 a.out`main at small.c:34:5
31 int i;
32
33 for (i = 0; i < NVARS; i++)
-> 34 ptrs[i] = input + i, incs[i] = i;
35 for (i = 0; i < NITER * NVARS; i++)
36 input[i] = i;
37 foo (NITER);
(lldb) fstep stepi
Assertion failed: (byte_size > 0 && byte_size <= 8 && "GetMaxU64 invalid byte_size!"), function GetMaxU64, file /home/overhead/llvm-project/lldb/source/Utility/DataExtractor.cpp, line 526
backtrace leading to the failure:
#0 0x00007f8c51f6b6f6 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/local/llvm-08d094a/bin/../lib/liblldb.so.16+0x18c96f6)
#1 0x00007f8c51a74f9c lldb_private::lldb_assert(bool, char const*, char const*, char const*, unsigned int) (/usr/local/llvm-08d094a/bin/../lib/liblldb.so.16+0x13d2f9c)
#2 0x00007f8c51a6d6c4 lldb_private::DataExtractor::GetAddress(unsigned long*) const (/usr/local/llvm-08d094a/bin/../lib/liblldb.so.16+0x13cb6c4)
#3 0x00007f8c51864578 DerefSizeExtractDataHelper(unsigned char*, unsigned long, lldb::ByteOrder, unsigned long) DWARFExpression.cpp:0:0
#4 0x00007f8c5186b62b lldb_private::DWARFExpression::Evaluate(lldb_private::ExecutionContext*, lldb_private::RegisterContext*, std::shared_ptr<lldb_private::Module>, lldb_private::DataExtractor const&, DWARFUnit const*, lldb::RegisterKind, lldb_private::Value const*, lldb_private::Value const*, lldb_private::Value&, lldb_private::Status*) (/usr/local/llvm-08d094a/bin/../lib/liblldb.so.16+0x11c962b)
#5 0x00007f8c518583bc lldb_private::DWARFExpressionList::Evaluate(lldb_private::ExecutionContext*, lldb_private::RegisterContext*, unsigned long, lldb_private::Value const*, lldb_private::Value const*, lldb_private::Value&, lldb_private::Status*) const (/usr/local/llvm-08d094a/bin/../lib/liblldb.so.16+0x11b63bc)
#6 0x00007f8c5181261e lldb_private::ValueObjectVariable::UpdateValue() (/usr/local/llvm-08d094a/bin/../lib/liblldb.so.16+0x117061e)
#7 0x00007f8c517f0b66 lldb_private::ValueObject::UpdateValueIfNeeded(bool) (.part.0) ValueObject.cpp:0:0
#8 0x00007f8c517f4788 lldb_private::ValueObject::GetValueAsCString() (/usr/local/llvm-08d094a/bin/../lib/liblldb.so.16+0x1152788)
#9 0x00007f8c516241d5 lldb::SBValue::GetValue() (/usr/local/llvm-08d094a/bin/../lib/liblldb.so.16+0xf821d5)
#10 0x00007f8c516e0cfe _wrap_SBValue_GetValue LLDBWrapPython.cpp:0:0
#11 0x00007f8c4fc5f68e (/lib/x86_64-linux-gnu/libpython3.10.so.1.0+0x12868e)
#12 0x00007f8c4fbb29c8 _PyEval_EvalFrameDefault (/lib/x86_64-linux-gnu/libpython3.10.so.1.0+0x7b9c8)
#13 0x00007f8c4fcf93af (/lib/x86_64-linux-gnu/libpython3.10.so.1.0+0x1c23af)
#14 0x00007f8c4fc1fde4 (/lib/x86_64-linux-gnu/libpython3.10.so.1.0+0xe8de4)
#15 0x00007f8c4fc678a5 _PyObject_GenericGetAttrWithDict (/lib/x86_64-linux-gnu/libpython3.10.so.1.0+0x1308a5)
#16 0x00007f8c4fc66f2b PyObject_GetAttr (/lib/x86_64-linux-gnu/libpython3.10.so.1.0+0x12ff2b)
#17 0x00007f8c4fbacb03 _PyEval_EvalFrameDefault (/lib/x86_64-linux-gnu/libpython3.10.so.1.0+0x75b03)
#18 0x00007f8c4fcf93af (/lib/x86_64-linux-gnu/libpython3.10.so.1.0+0x1c23af)
#19 0x00007f8c4fbaf63e _PyEval_EvalFrameDefault (/lib/x86_64-linux-gnu/libpython3.10.so.1.0+0x7863e)
#20 0x00007f8c4fcf93af (/lib/x86_64-linux-gnu/libpython3.10.so.1.0+0x1c23af)
#21 0x00007f8c51db9dc2 lldb_private::python::PythonCallable::operator()(std::initializer_list<lldb_private::python::PythonObject>) (/usr/local/llvm-08d094a/bin/../lib/liblldb.so.16+0x1717dc2)
#22 0x00007f8c51727e6c lldb_private::LLDBSwigPythonCallCommand(char const*, char const*, std::shared_ptr<lldb_private::Debugger>, char const*, lldb_private::CommandReturnObject&, std::shared_ptr<lldb_private::ExecutionContextRef>) (/usr/local/llvm-08d094a/bin/../lib/liblldb.so.16+0x1085e6c)
#23 0x00007f8c51dc7e84 lldb_private::ScriptInterpreterPythonImpl::RunScriptBasedCommand(char const*, llvm::StringRef, lldb_private::ScriptedCommandSynchronicity, lldb_private::CommandReturnObject&, lldb_private::Status&, lldb_private::ExecutionContext const&) (/usr/local/llvm-08d094a/bin/../lib/liblldb.so.16+0x1725e84)
#24 0x00007f8c53c5bd15 CommandObjectPythonFunction::DoExecute(llvm::StringRef, lldb_private::CommandReturnObject&) (/usr/local/llvm-08d094a/bin/../lib/liblldb.so.16+0x35b9d15)
#25 0x00007f8c518ad783 lldb_private::CommandObjectRaw::Execute(char const*, lldb_private::CommandReturnObject&) (/usr/local/llvm-08d094a/bin/../lib/liblldb.so.16+0x120b783)
#26 0x00007f8c518a9c60 lldb_private::CommandInterpreter::HandleCommand(char const*, lldb_private::LazyBool, lldb_private::CommandReturnObject&) (/usr/local/llvm-08d094a/bin/../lib/liblldb.so.16+0x1207c60)
#27 0x00007f8c518aa1c2 lldb_private::CommandInterpreter::IOHandlerInputComplete(lldb_private::IOHandler&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) (/usr/local/llvm-08d094a/bin/../lib/liblldb.so.16+0x12081c2)
#28 0x00007f8c517aed0c lldb_private::IOHandlerEditline::Run() (/usr/local/llvm-08d094a/bin/../lib/liblldb.so.16+0x110cd0c)
#29 0x00007f8c51782a6a lldb_private::Debugger::RunIOHandlers() (/usr/local/llvm-08d094a/bin/../lib/liblldb.so.16+0x10e0a6a)
#30 0x00007f8c51899476 lldb_private::CommandInterpreter::RunCommandInterpreter(lldb_private::CommandInterpreterRunOptions&) (/usr/local/llvm-08d094a/bin/../lib/liblldb.so.16+0x11f7476)
#31 0x00007f8c514df326 lldb::SBDebugger::RunCommandInterpreter(bool, bool) (/usr/local/llvm-08d094a/bin/../lib/liblldb.so.16+0xe3d326)
#32 0x000055f1fa44486f Driver::MainLoop() (/usr/local/llvm-08d094a/bin/lldb+0xf86f)
#33 0x000055f1fa4432da main (/usr/local/llvm-08d094a/bin/lldb+0xe2da)
#34 0x00007f8c50137d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#35 0x00007f8c50137e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#36 0x000055f1fa4433d5 _start (/usr/local/llvm-08d094a/bin/lldb+0xe3d5)
please file a bug report against lldb reporting this failure log, and as many details as possible
*** stack smashing detected ***: terminated
LLDB diagnostics will be written to /tmp/diagnostics-8a3f09
Please include the directory content when filing a bug report
Aborted (core dumped)
```
I've written a Python script to register an fstep command for step-by-step debugging of a binary. While stepping through the program at the instruction level and retrieving the respective information, LLDB crashes. I’ve also uploaded the binary that was being debugged with LLDB, as shown below.
[a.out.zip](https://github.com/user-attachments/files/17648779/a.out.zip)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEW19z46iy_zTKCxWXhP4_5MF24j2pO7uZSmZ2z31yIdGyOSMjFSAnmU9_C5BsSZazSY7nrivrtaC7-XXTNN2gIVKyDQe4ccKFE95ekUZtK3HDyI7wir_uqkbm8iqr6OuNE7kODlBeEr5B19d7EJJVXLe6t447t-1tK_KimTtzkYOTrVK1dPy5g1cOXu2YEJWY8f80M6DNLOcOXm2YcvCqLPe761pU_4FczTZMITehbhoQF4Iw9iOX0CRLg8z1YoppjuMYojTOSRw5OLUIvhGxAeX4c_SSROsouG74D1498-uS8eblesOblm4rgFC0qyiUmrquJHuxXfdcKlKWQG-Z0F0OXjVSaHRVTsoOZYvMwauMccvYflsTlSXNJixkmi9oIAF7ZmR92FKoncWPS2jZNZbPck8YLCcKyR0py1l-sJb-Yf_sI_YpFIwD-uP-290jCk6a_5w_PiF8Qv779y_f7h2c_NvBKXLCZafCvx2cIFebBC_tg9d_wP0Hv_8Q9B_C_kPUf4j7D0n_IW0fRmC8PhivD8brg_H6YLw-GK8PxuuD8fpgvD4YLz04xdhwt3fLL_PHO227-z9u74z9GM8d7DvYNy3I8W91k3TChSUJb89IWfWlOHheKzEWVCsxEISXSIBsSjUmPJniLw8PX_vyJ9jwQnOeDKwHGUOxpENNxyMuH77-78P3b6eD9jUwYE-w9I1dlBVRLSrNaXxY6-4v-gRH0ScEjKtuBk767Pe-YhSt10QpwbJGwXrt4MTBCa8YLxkH4wytCxRVpSOSFsqPfhEvOjfVHWY9aaqjf6SHIRGyiMd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