Message ID | 20180516174302.29092-1-tom@tromey.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 24445 invoked by alias); 16 May 2018 17:43:10 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 22839 invoked by uid 89); 16 May 2018 17:43:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=fedora, Fedora, 1527 X-HELO: gateway33.websitewelcome.com Received: from gateway33.websitewelcome.com (HELO gateway33.websitewelcome.com) (192.185.145.190) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 16 May 2018 17:43:08 +0000 Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 99D061066C0 for <gdb-patches@sourceware.org>; Wed, 16 May 2018 12:43:06 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id J0SAfd7dIbXuJJ0SAfvvLl; Wed, 16 May 2018 12:43:06 -0500 X-Authority-Reason: nr=8 Received: from 174-29-44-154.hlrn.qwest.net ([174.29.44.154]:58656 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from <tom@tromey.com>) id 1fJ0SA-003N57-Ci; Wed, 16 May 2018 12:43:06 -0500 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 11:43:02 -0600 Message-Id: <20180516174302.29092-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fJ0SA-003N57-Ci X-Source-Sender: 174-29-44-154.hlrn.qwest.net (bapiya.Home) [174.29.44.154]:58656 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes |
Commit Message
Tom Tromey
May 16, 2018, 5:43 p.m. UTC
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(-)
Comments
On 16/05/18 18:43, Tom Tromey wrote: > 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. */ > LGTM Cheers Phil
On 05/17/2018 11:32 AM, Phil Muldoon wrote: > On 16/05/18 18:43, Tom Tromey wrote: > LGTM Thanks Phil. LGTM too. Thanks, Pedro Alves
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. */