Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA] Initialize py_type_printers in ext_lang_type_printers
Date: Wed, 16 May 2018 18:20:00 -0000	[thread overview]
Message-ID: <20180516174302.29092-1-tom@tromey.com> (raw)

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-16  Tom Tromey  <tom@tromey.com>

	* extension.h (struct ext_lang_type_printers) <py_type_printers>:
	Initialize.
---
 gdb/ChangeLog   | 5 +++++
 gdb/extension.h | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gdb/extension.h b/gdb/extension.h
index abde5e54e1..0c8c4ee934 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.  */
-- 
2.13.6


             reply	other threads:[~2018-05-16 17:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-16 18:20 Tom Tromey [this message]
2018-05-17 13:25 ` Phil Muldoon
2018-05-17 13:40   ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180516174302.29092-1-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox