From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 72369 invoked by alias); 17 May 2018 10:32:47 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 72307 invoked by uid 89); 17 May 2018 10:32:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=H*r:sk:g21-v6s X-HELO: mail-wr0-f169.google.com Received: from mail-wr0-f169.google.com (HELO mail-wr0-f169.google.com) (209.85.128.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 17 May 2018 10:32:45 +0000 Received: by mail-wr0-f169.google.com with SMTP id g21-v6so5121222wrb.8 for ; Thu, 17 May 2018 03:32:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=i/gwmv7scJgEAoprCBFeEzn4tkpNlYVjIeftA+rFoOU=; b=bFulwgz9b9LowfdYbZKU4ELk8k3C1oDdl+vFSCkXxgbRUqiW0r7wG9SSQKi4r2PE41 9WG2y76t4DlYTmU3Pi8fWPE9bIo3r0mC+3YaHJWJwNQkwQ5PHMejcGRxUqsEzFTGNvRF vK3KJ+Ps+sUL+bHgMvEbiGIFdZ0LcC+waUaFZK3U37y13Irep/KhLba9F2SdBIM/xGO+ 1Zf5DkK9SpSznVJow4guOeJWUQVmzz0dUhuJjRhW/4U2kj09JnxiOjVIv4idY4/FIbNH BeK76oTBGv1k9nbFYpUXV5YL5XO4SLzJ2Bh3gURdbffGErsynWyxTBfC6Q0FdEXNS9pl JAwQ== X-Gm-Message-State: ALKqPwfs96aqOPfSHXdHuRHTYN6YSo/J8uywFCKIiPup5yeUcq8RNu99 0ZKP6NK7ro7D3JrLzuNJL/otz+ElH8o= X-Google-Smtp-Source: AB8JxZokBnS0dOnoqBMf8YuoWKy2HyPFztQepaIURTrwD+ux12VdKFK/+JgkZPhlF0vhPjeLgn8lMQ== X-Received: by 2002:adf:b509:: with SMTP id a9-v6mr3762440wrd.191.1526553162537; Thu, 17 May 2018 03:32:42 -0700 (PDT) Received: from ?IPv6:2a02:c7f:ae6a:ed00:4685:ff:fe66:9f4? ([2a02:c7f:ae6a:ed00:4685:ff:fe66:9f4]) by smtp.gmail.com with ESMTPSA id c21-v6sm6599784wre.81.2018.05.17.03.32.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 May 2018 03:32:41 -0700 (PDT) Subject: Re: [RFA] Initialize py_type_printers in ext_lang_type_printers To: Tom Tromey , gdb-patches@sourceware.org References: <20180516174302.29092-1-tom@tromey.com> From: Phil Muldoon Message-ID: <4c9a10c3-7527-676c-abc0-7f48a83e209c@redhat.com> Date: Thu, 17 May 2018 13:25:00 -0000 MIME-Version: 1.0 In-Reply-To: <20180516174302.29092-1-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2018-05/txt/msg00375.txt.bz2 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 > > * extension.h (struct ext_lang_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