Debugging Clang with LLDB

Hi,
I’m trying to use LLDB to debug Clang built with the LLVM toolchain.

However, whenever I try to evaluate a method call in the debugger,
I get the following error instead of the actual result:

error: Execution was interrupted,
reason: signal SIGSEGV: invalid address (fault address: 0x0).

(See the full output below.)

What am I doing wrong? GDB works fine in this scenario. LLDB works
fine with other projects I have on hand. Any help appreciated.

Thanks,
Jan

This error message indicates that the expression you compiled "argv.size()" crashed with a SIGSEV. If this is unoptimized code this looks like it could be a bug in LLDB. What OS are you using and what compiler did you compile clang with?

-- adrian

The argv.size() expression doesn’t crash with SIGSEGV when used directly in the Clang binary though, only when evaluated in LLDB.
I’m running x64 Linux (Ubuntu 18.04) and compiled the binary in debug mode using Clang, LLD, libc++ (all in version 8.0.0) installed from the official APT repository.

That sounds like an LLDB bug then. If you are interested you could report it on the LLVM bugzilla and include steps to reproduce and most importantly a full expression log (run "log enable lldb expr") before running your command.

+Jonas—are LLDB reproducers usable enough for this example already?

-- adrian

The `argv.size()` expression doesn't crash with SIGSEGV when used directly in the Clang binary though, only when evaluated in LLDB.
I'm running x64 Linux (Ubuntu 18.04) and compiled the binary in debug mode using Clang, LLD, libc++ (all in version 8.0.0) installed from the official APT repository.

That sounds like an LLDB bug then. If you are interested you could report it on the LLVM bugzilla and include steps to reproduce and most importantly a full expression log (run "log enable lldb expr") before running your command.

+Jonas—are LLDB reproducers usable enough for this example already?

It might be a good test case, let's find out!

If you don't mind giving this experimental feature a shot, you can pass --capture to the lldb driver. After you see the error, type "reproducer generate" in the command and it will tell you the path where it generated the reproducer. The reproducer is a directory, which you'd have to compress yourself (at least for now). Keep in mind that it will include binaries and debug info, but since it's open source clang I assume that should be fine.

I’m happy to try reproducers out, however when I run $ lldb-8 --capture ./lldb-reproducer ./llvm-project/build/bin/clang and reproducer generate after the error occurs, it only creates index.yaml and gdb-remote.yaml.
That’s in line with the reproducers description here: http://lists.llvm.org/pipermail/lldb-dev/2018-September/014184.html
I just wanted to point the current behaviour out.

I’ll submit the whole Clang binary with debug info anyways, if Bugzilla lets me.
Thanks for the help!

The bug report can be found here: https://bugs.llvm.org/show_bug.cgi?id=41237
Turns out, the segmentation fault occurs only when the Clang binary was linked with LLD or GNU Gold.
Binary linked with GNU ld works fine.