-
-
Notifications
You must be signed in to change notification settings - Fork 710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Stack is not displayed when attaching to gdbserver inside a container #901
Comments
Using gef-remote should help here. |
Thanks there is no issue when using |
Actually this also happens with gef-remote if the inferior process forks and the debugger attaches to the child. Everything works fine until the inferior process passes a fork call. Sample program for testing
Compile with: Steps to reproduce Log if fork is called
|
I can reproduce the issue and found the problem: GDB is triggering GEFs |
@Ultimator14 can you check if the draft PR #903 fixes the issue for you as well? |
Yes, #903 fixes the issue for me. |
I noticed that this bug also occurs with any binary if the current working directory contains spaces. Steps to reproduce:
When running gdbserver directly on the host, the error also occurs but the stack is display nevertheless. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. You can reopen it by adding a comment to this issue. |
Both #901 (comment) and #901 (comment) still occur in current dev. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. You can reopen it by adding a comment to this issue. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. You can reopen it by adding a comment to this issue. |
This issue has been automatically closed because it has not had recent activity. If you are the owner of this issue, you can either re-open it and provide a more complete description; or create a new issue. Thank you for your contributions. |
Will try to fix this one, reopening. |
Seems gef handles this now. @Ultimator14: I know this issue is super old, but if you still use gef, I would be curious if you could still reproduce on main. |
I can still reproduce both issues on main (using the program from #901 (comment)) Container (same commands for both setups)
1. Unmapped address after forkCurrent directory:
2. Unmapped address at any point if path contains spacesCurrent directory:
|
I'll focus on #2. Confirming that I can reproduce the issue, and that I cannot if I rerun from a directory without spaces. |
Can you please try making this change? diff --git a/gef.py b/gef.py
index 5435c79..feb4c31 100644
--- a/gef.py
+++ b/gef.py
@@ -10902,7 +10902,7 @@ class GefRemoteSessionManager(GefSessionManager):
return True
tgt.parent.mkdir(parents=True, exist_ok=True)
dbg(f"[remote] downloading '{src}' -> '{tgt}'")
- gdb.execute(f"remote get {src} {tgt.absolute()}")
+ gdb.execute(f"remote get '{src}' '{tgt.absolute()}'")
return tgt.exists()
def connect(self, pid: int) -> bool: |
And for the fork issue: diff --git a/gef.py b/gef.py
index 5435c79..a5a7d35 100644
--- a/gef.py
+++ b/gef.py
@@ -3554,19 +3554,25 @@ def new_objfile_handler(evt: Optional["gdb.NewObjFileEvent"]) -> None:
return
-def exit_handler(_: "gdb.ExitedEvent") -> None:
+def exit_handler(e: "gdb.ExitedEvent") -> None:
"""GDB event handler for exit cases."""
global gef
# flush the caches
reset_all_caches()
# disconnect properly the remote session
- gef.session.qemu_mode = False
- if gef.session.remote:
- gef.session.remote.close()
- del gef.session.remote
- gef.session.remote = None
- gef.session.remote_initializing = False
+ if hasattr(e, "exit_code"):
+ gef.session.qemu_mode = False
+ if gef.session.remote:
+ gef.session.remote.close()
+ del gef.session.remote
+ gef.session.remote = None
+ gef.session.remote_initializing = False |
Both patches work. |
As I looked into #901, I found that we often don't quote filepaths in `gdb.execute`. This began lazy grep that tries to ID where we do this, and fixes where we can. Noticed that we cannot use quotes in the filename when setting up logging, so it instead restricts the logging path to one without spaces.
GEF+GDB version
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
Since commit 546f4b1 the stack is not displayed anymore. The stack field just displays
[!] Unmapped address
. Additionally I get a[*] Omitting remote file
warning (see example below).Since commit 430d9d3, the
[*] Omitting remote file '/lib64/ld-linux-x86-64.so.2'
warning is changed to several warnings of the typeThe pull request #897 removes the
[*] Failed to find objfile or not a valid file format
warnings but creates aPython 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
Describe your issue. Without a proper reproduction step-by-step, your issue will be ignored.
docker run --tty --interactive --rm -v "$PWD":/workdir -w /workdir ultimator14/arch-interactive /bin/bash
gdbserver 0.0.0.0:4101 ./mybinary
gef ./mybinary
target remote 172.17.0.2:4101
Minimalist test case
This happens with every binary
Additional context?
No response
The text was updated successfully, but these errors were encountered: