cs01 / cs01/gdbgui

gdbgui fails with an unhandled UnicodeDecodeError

Open
#407 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
10.4k
Forks
521
PR merge metrics
No merged PRs in 30d

Description

When debugging some c++ code via gdbgui, gdbgui ceases to work and I get a popup informing that "The connection to the gdb session has been closed. This tab will no longer function as expected". I have to restart gdbgui to recover.

The terminal in which gdbgui is running offers these diagnostics:

'utf-8' codec can't decode byte 0x90 in position 2006: invalid start byte
Traceback (most recent call last):
File "/home/jim/.local/pipx/venvs/gdbgui/lib/python3.8/site-packages/gdbgui/server/app.py", line 284, in check_and_forward_pty_output
response = debug_session.pty_for_debugged_program.read()
File "/home/jim/.local/pipx/venvs/gdbgui/lib/python3.8/site-packages/gdbgui/server/ptylib.py", line 78, in read
response = os.read(self.stdout, self.max_read_bytes).decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x90 in position 2006: invalid start byte

Patching the relevant section in ptylib.py to intercept that error as demonstrated in the attached patch prevents the utf8 conversion issue from crashing gdbgui. But maybe there's a better fix I'm not aware of.

[ptylib.patch.txt](https://github.com/cs01/gdbgui/files/7498166/ptylib.patch.txt)

Contributor guide

Open the contributing guide

Research direction

The traceback points to server/ptylib.py, especially the read path called by check_and_forward_pty_output. Reproduce the failure with non-UTF-8 program output and inspect the attached ptylib.patch.txt before choosing the handling behavior. Done means invalid byte sequences no longer terminate the gdb session while the existing output path still functions.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
devtools
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.