rizinorg / cutter

Free and Open Source Reverse Engineering Platform powered by rizin
https://cutter.re
GNU General Public License v3.0
15.8k stars 1.15k forks source link

GDB Server gets EOF from Cutter #2829

Open rgnter opened 2 years ago

rgnter commented 2 years ago

Environment information

Describe the bug Communication with gdb server fails(due to protocol error?) and cutter tries to proceed with debugging but runs into segfault.

Gdb server from winbuilds(arch x64) ran with command gdbserver --remote-debug 127.0.0.1:53535 file.exe (target executable arch is x32)

outputs following:

Listening on port 53535
Remote debugging from host 127.0.0.1
readchar: Got EOF
[getpkt: discarding char ' ']
Remote side has terminated connection.  GDBserver will reopen the connection.

To Reproduce Steps to reproduce the behavior:

  1. Setup cutter project(with analyzed binary)
  2. Setup gdb server (run with elevation)
  3. Connect to gdb server from cutter

Expected behavior Debugger should successfuly connect and proceed with debugging.

Additional context Dump: crash.zip

XVilka commented 2 years ago

@rgnter could you please retry with the 2.0.4-rc2 prerelease? There were some important GDB fixes in it. There is a chance it is fixed. https://github.com/rizinorg/cutter/releases/tag/v2.0.4-rc2

rgnter commented 2 years ago

Does not work with version you have provided me with.

I have compiled cutter and found the issue: The DebugActions::onAttachedRemoteDebugger is for some unknown reason to me, being called twice.

A simple null check in the function fixes everything. image

Fixed in PR #2830

Kyllingene commented 2 years ago

The issue still occurs for me:

Remote debugging from host 127.0.0.1
[remote] readchar: readchar: Got EOF
[remote] getpkt: [getpkt: discarding char '�']
Remote side has terminated connection.  GDBserver will reopen the connection.