]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
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)
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

index eb3c5f772fee66a436ef7187373ca15aabeb23ce..4ae46c1ae44afcc517166f77590ecef2c3b3f891 100644 (file)
@@ -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
index abde5e54e16f19449cc65d74de2d4c9be49f1aad..0c8c4ee93435f3c9c51eaa193458b53a279de663 100644 (file)
@@ -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.  */