gdbgui fails with an unhandled UnicodeDecodeError
- 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
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