llvm / llvm/llvm-project

[LLDB] debuginfod not cancel-able with Ctrl-C before server responds

Open
#216,629 2 comments 0 reactions 0 assignees View on GitHub
lldb
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

LLDB version: lldb version 22.1.8
OS: archlinux 7.1.5-arch1-2

Run a make-pretend debuginfod server which never responds:
```bash
socat TCP-LISTEN:45678,bind=127.0.0.1,reuseaddr,fork EXEC:'sleep 120'
```
Run lldb with it:
```bash
$ DEBUGINFOD_CACHE_PATH=$(mktemp -d /tmp/lldb-debuginfod-test.XXXXXX) DEBUGINFOD_URLS=http://127.0.0.1:45678/ lldb /bin/sh
```

You will get:
```bash
(lldb) target create "/bin/sh"

```
i.e. LLDB indefinitely (?) hanging waiting on the "debuginfod" server response. This by itself is already bad, but the worse part is that:
```bash
(lldb) target create "/bin/sh"
^C^C^C^C^C^C^C^C
```
You can't exit out of that state. You have to kill LLDB externally. If you run it again, you're stuck again. Sometimes I've seen the debuginfod cache get updated with a "i couldn't fetch this, don't try again" flag, but it's not very consistent.

Now, the fun part is that this issue is not contrived:
```bash
DEBUGINFOD_CACHE_PATH=$(mktemp -d /tmp/lldb-debuginfod-test.XXXXXX) DEBUGINFOD_URLS=https://debuginfod.ubuntu.com lldb /bin/sh
```
Ubuntu's debuginfod server has been borked for months now (https://bugs.launchpad.net/ubuntu-debuginfod/+bug/2163016), so if you're using LLDB on ubuntu, you're not having a fun time.

I'm not sure if the required condition for the ubuntu server to stall is that you ask it for a binary that it does not have debug info for. Here I'm asking it for the debug info of arch's /bin/sh which it obviously won't have. Note that still, most of the programs you compile yourself and want to debug with LLDB will not be available in ubuntus debuginfod server.

If you set `DEBUGINFOD_TIMEOUT=5` you'll wait like 10 seconds instead of forever. I think LLDB does one retry which is why it takes 10s instead of 5s. This should be fixed by setting `DEBUGINFOD_RETRY_LIMIT=0`, but LLDB does not seem to respect it (which makes the third lldb + debuginfod problem in this issue :p ).

The bug is also present in GDB and their libdebuginfod implementation, but https://sourceware.org/bugzilla/ is currently down so not sure if there is a relevant issue.

downstream: https://github.com/pwndbg/pwndbg/pull/4079

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the hang with the lldb, DEBUGINFOD_URLS, DEBUGINFOD_TIMEOUT, and DEBUGINFOD_RETRY_LIMIT commands shown in the issue. Trace LLDB's debuginfod request and Ctrl-C handling; done means a stalled request can be cancelled or LLDB can exit, and the retry-limit setting is respected.

Written by the indexing model from the issue text.

Assessment

Domain
cli, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.