gef: [Bug] Stack is not displayed when attaching to gdbserver inside a container

GEF+GDB version

GEF: (Standalone)
Blob Hash(/usr/share/gef/gef.py): 0653da00ca754d9580d60a330907c988d6468dee
SHA256(/usr/share/gef/gef.py): f14771fa2cafaf7bca7f8b2a53db54c85f6612f42ac8ff80aaaa476fd7553e69
GDB: 12.1
GDB-Python: 3.10

Operating System

Gentoo Linux

Describe the issue you encountered

I’m using gdbserver to debug my binaries inside a docker container.

The setup is as follows

Host:               Container:
--------------------------------
gef   -> connect -> gdbserver
 |                      |
binary  <--- volume <---

Since commit 546f4b1824802f176878a41ef2117cf18537188f the stack is not displayed anymore. The stack field just displays [!] Unmapped address. Additionally I get a [*] Omitting remote file warning (see example below).

...
Reading /usr/lib/debug/lib64//ld-linux-x86-64.so.2.debug from remote target...
Reading target:/usr/lib/debug/lib64//ld-linux-x86-64.so.2.debug from remote target...
[*] Omitting remote file '/lib64/ld-linux-x86-64.so.2'
Reading /usr/lib/debug/.build-id/8a/29dcb265d5fa49083ddb942a7581a54dade086.debug from remote target...
0x00007f4f5d224730 in ?? () from target:/lib64/ld-linux-x86-64.so.2
[ Legend: Modified register | Code | Heap | Stack | String ]
───────────────────────────────────────────────────────────────── registers ────
$rax   : 0x0               

...
$r14   : 0x0               
$r15   : 0x7f4f5d23c000    
$eflags: [ZERO carry PARITY adjust sign trap INTERRUPT direction overflow resume virtualx86 identification]
$cs: 0x33 $ss: 0x2b $ds: 0x00 $es: 0x00 $fs: 0x00 $gs: 0x00 
───────────────────────────────────────────────────────────────────── stack ────
[!] Unmapped address: '0x7ffed79afbf0'
─────────────────────────────────────────────────────────────── code:x86:64 ────
0x400689 <win+18>         ret    
...

Since commit 430d9d3f7efab6e55215c07bd1694c3a4c4cb6cd, the [*] Omitting remote file '/lib64/ld-linux-x86-64.so.2' warning is changed to several warnings of the type

[*] Failed to find objfile or not a valid file format: [Errno 2] Datei oder Verzeichnis nicht gefunden: 'target:/lib64/ld-linux-x86-64.so.2'
Reading /usr/lib/debug/.build-id/8a/29dcb265d5fa49083ddb942a7581a54dade086.debug from remote target...
[*] Failed to find objfile or not a valid file format: [Errno 2] Datei oder Verzeichnis nicht gefunden: 'system-supplied DSO at 0x7ffec83c2000'

The pull request #897 removes the [*] Failed to find objfile or not a valid file format warnings but creates a Python Exception.
The issue is not fixed in HEAD.

Do you read the docs and look at previously closed issues/PRs for similar cases?

Yes

Architecture impacted

  • X86
  • X64
  • ARM
  • ARM64
  • MIPS
  • MIPS64
  • PPC
  • PPC64
  • RISCV

Describe your issue. Without a proper reproduction step-by-step, your issue will be ignored.

  1. Place the binary to debug in the current directory
  2. Start the docker container docker run --tty --interactive --rm -v "$PWD":/workdir -w /workdir ultimator14/arch-interactive /bin/bash
  3. Start gdbserver in the container gdbserver 0.0.0.0:4101 ./mybinary
  4. Start gef outside the container gef ./mybinary
  5. Connect gef to gdbserver inside the container target remote 172.17.0.2:4101
  6. See that gef does not display the stack

Minimalist test case

This happens with every binary

Additional context?

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Both patches work.
With the first one applied, the stack is also shown with spaces in path. The second one keeps the stack displayed after a fork.
I applied them both and was not able to get another Unmapped address. TYVM

Yes, #903 fixes the issue for me.