| Issue |
115166
|
| Summary |
LLDB crashed with Assertion failed in function GetMaxU64 of file lldb/source/Utility/DataExtractor.cpp
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
iamanonymouscs
|
`$ 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)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs