diff options
author | Tom Tromey <tom@tromey.com> | 2018-05-16 11:39:09 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-05-17 07:29:12 -0600 |
commit | fe10fe3131e688d528877706db1e98e15434c0dc (patch) | |
tree | 328cc966cd8184baa663d4107a46fbe8cfafd5b1 | |
parent | 1a87f0eedcf3fb54b665d6c92007c721c6b25218 (diff) | |
download | gdb-fe10fe3131e688d528877706db1e98e15434c0dc.zip gdb-fe10fe3131e688d528877706db1e98e15434c0dc.tar.gz gdb-fe10fe3131e688d528877706db1e98e15434c0dc.tar.bz2 |
Initialize py_type_printers in ext_lang_type_printers
When running gdb in the build directory without passing
--data-directory, I noticed I could provoke a crash by:
$ ./gdb -nx ./gdb
(gdb) ptype/o struct dwarf2_per_objfile
... and then trying to "q" out at the pagination prompt.
valgrind complained about an uninitialized use of py_type_printers.
Initializing this member fixes the bug.
I believe this bug can occur even when the gdb Python libraries are
available, for example if get_type_recognizers fails.
Tested by hand on x86-64 Fedora 26. No test case because it seemed
difficult to guarantee failures.
gdb/ChangeLog
2018-05-17 Tom Tromey <tom@tromey.com>
* extension.h (struct ext_lang_type_printers) <py_type_printers>:
Initialize.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/extension.h | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index eb3c5f7..4ae46c1 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2018-05-17 Tom Tromey <tom@tromey.com> + + * extension.h (struct ext_lang_type_printers) <py_type_printers>: + Initialize. + 2018-05-16 Maciej W. Rozycki <macro@mips.com> PR gdb/22286 diff --git a/gdb/extension.h b/gdb/extension.h index abde5e5..0c8c4ee 100644 --- a/gdb/extension.h +++ b/gdb/extension.h @@ -152,7 +152,7 @@ struct ext_lang_type_printers DISABLE_COPY_AND_ASSIGN (ext_lang_type_printers); /* Type-printers from Python. */ - void *py_type_printers; + void *py_type_printers = nullptr; }; /* The return code for some API calls. */ |