Initialize py_type_printers in ext_lang_type_printers
authorTom Tromey <tom@tromey.com>
Wed, 16 May 2018 17:39:09 +0000 (11:39 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 17 May 2018 13:29:12 +0000 (07:29 -0600)
commitfe10fe3131e688d528877706db1e98e15434c0dc
tree328cc966cd8184baa663d4107a46fbe8cfafd5b1
parent1a87f0eedcf3fb54b665d6c92007c721c6b25218
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.
gdb/ChangeLog
gdb/extension.h