From patchwork Sat Aug 25 15:56:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 29049 Received: (qmail 99237 invoked by alias); 25 Aug 2018 15:56:14 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 99221 invoked by uid 89); 25 Aug 2018 15:56:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=am, UD:ca, a.m X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 25 Aug 2018 15:56:12 +0000 Received: from [10.0.0.11] (unknown [192.222.164.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id CDE3D1E012; Sat, 25 Aug 2018 11:56:09 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=simark.ca; s=mail; t=1535212570; bh=WMOzMT5sjrmgdLaIOSbZ8wK4mSlrhiLcnsAeoV/Jc4o=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=D+VwpsVGXH/lB03MukYdtlw28Tidt10MHtMB1bhD0FsiOiyE5iNMcX3z/nfAIctCL wHUWMpXBi6ZyojTqSP/yXuNIBYE4+IXXEMRgv/C3K6iDwdkMal5mzNVGcG696WxKr6 vussbWWw4Q5F5dnxTTy1NGMzkCzJz9u+eEJ+TeG8= Subject: Re: [PATCH v2] Fix 8.2 regression in gdb.python/py-evthreads.exp w/ gdbserver (PR gdb/23379) To: Tom Tromey , Pedro Alves Cc: Simon Marchi , gdb-patches@sourceware.org References: <20180824174616.3306-1-palves@redhat.com> <81f69245-7bad-a9f8-58ef-7f8ead16e71f@ericsson.com> <874lfi1osj.fsf@tromey.com> From: Simon Marchi Message-ID: <50e8c465-415e-0f00-562a-1508b4fad5cb@simark.ca> Date: Sat, 25 Aug 2018 11:56:09 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <874lfi1osj.fsf@tromey.com> On 2018-08-25 10:52 a.m., Tom Tromey wrote: >>>>>> "Pedro" == Pedro Alves writes: > > Pedro> * python/py-threadevent.c (get_event_thread): Rename to ... > Pedro> (py_get_event_thread): ... this, make extern, add 'ptid' parameter > > I get this warning now: > > ../../binutils-gdb/gdb/python/py-threadevent.c: In function ‘PyObject* py_get_event_thread(ptid_t)’: > ../../binutils-gdb/gdb/python/py-threadevent.c:39:3: warning: ‘pythread’ may be used uninitialized in this function [-Wmaybe-uninitialized] > > ... which seems legitimate to me: > > PyObject *pythread; > > if (non_stop) > { > thread_info *thread = find_thread_ptid (ptid); > if (thread != nullptr) > pythread = (PyObject *) thread_to_thread_object (thread); > // ... else pythread is uninitialized ... > } > > pythread should be set to nullptr where I stuck the comment (or > initialized to nullptr). > > Tom > Huh indeed, thanks for pointing it out. I wonder why I don't get the warning with my gcc 8.2.0... I pushed this patch to master and the 8.2 branch. From bbbbbceebc342d583057a11d88bae85f451cd904 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Sat, 25 Aug 2018 11:52:24 -0400 Subject: [PATCH] Initialize variable in py_get_event_thread The pythread variable could be used without being initialized, fix it by initializing it to nullptr. gdb/ChangeLog: * python/py-threadevent.c (py_get_event_thread): Initialize pythread. --- gdb/ChangeLog | 5 +++++ gdb/python/py-threadevent.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 12dda6c541d9..9e3d6bc27acd 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2018-08-25 Simon Marchi + + * python/py-threadevent.c (py_get_event_thread): Initialize + pythread. + 2018-08-24 Pedro Alves * python/py-bpevent.c (create_breakpoint_event_object): Use diff --git a/gdb/python/py-threadevent.c b/gdb/python/py-threadevent.c index a78f0a38310c..4f822b4ae09c 100644 --- a/gdb/python/py-threadevent.c +++ b/gdb/python/py-threadevent.c @@ -25,7 +25,7 @@ PyObject * py_get_event_thread (ptid_t ptid) { - PyObject *pythread; + PyObject *pythread = nullptr; if (non_stop) { @@ -36,7 +36,7 @@ py_get_event_thread (ptid_t ptid) else pythread = Py_None; - if (!pythread) + if (pythread == nullptr) { PyErr_SetString (PyExc_RuntimeError, "Could not find event thread"); return NULL;