This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Fix GDB crash when registers cannot be modified.
- From: Philippe Waroquiers <philippe at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 20 Apr 2019 13:39:19 -0000
- Subject: [binutils-gdb] Fix GDB crash when registers cannot be modified.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f2ae8bc88390f91cca8531823db51a8e35f0a0a0
commit f2ae8bc88390f91cca8531823db51a8e35f0a0a0
Author: Philippe Waroquiers <philippe.waroquiers@skynet.be>
Date: Sat Apr 13 10:22:41 2019 +0200
Fix GDB crash when registers cannot be modified.
This crash was detected when using GDB with the valgrind gdbserver.
To reproduce:
valgrind sleep 10000
In another window:
gdb
target remote | vgdb
p printf("make sleep print something\n")
=>
terminate called after throwing an instance of 'gdb_exception_error'
Aborted
The problem is that the valgrind gdbserver does not allow to change
registers when the inferior is blocked in a system call.
GDB then raises an exception. The exception causes the destructor
of
typedef std::unique_ptr<infcall_suspend_state, infcall_suspend_state_deleter>
infcall_suspend_state_up;
to be called. This destructor itself tries to restore the value of
the registers, and fails similarly. We must catch the exception in
the destructor to avoid crashing GDB.
If the destructor encounters a problem, no warning is produced if
there is an uncaught exception, as in this case, the user will already
be informed of a problem via this exception.
With this change, no crash anymore, and all the valgrind 3.15 tests
pass succesfully.
gdb/ChangeLog
2019-04-19 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* inferior.h (struct infcall_suspend_state_deleter):
Catch exception in destructor to avoid crash.
Diff:
---
gdb/ChangeLog | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 80f18cd..0bd363e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -79,6 +79,11 @@
2019-04-19 Philippe Waroquiers <philippe.waroquiers@skynet.be>
+ * inferior.h (struct infcall_suspend_state_deleter):
+ Catch exception in destructor to avoid crash.
+
+2019-04-19 Philippe Waroquiers <philippe.waroquiers@skynet.be>
+
* cli/cli-cmds.c (_initialize_cli_cmds): Move "shell" "!" alias
close to the add_com "shell".