Message ID | 20180410173704.21702-1-tom@tromey.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 82017 invoked by alias); 10 Apr 2018 17:37: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 82006 invoked by uid 89); 10 Apr 2018 17:37:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.2 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=theoretical X-HELO: gateway33.websitewelcome.com Received: from gateway33.websitewelcome.com (HELO gateway33.websitewelcome.com) (192.185.146.80) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Apr 2018 17:37:07 +0000 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 9B152214A5 for <gdb-patches@sourceware.org>; Tue, 10 Apr 2018 12:37:06 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 5xCcfLxRZ9sXi5xCcfLoL6; Tue, 10 Apr 2018 12:37:06 -0500 Received: from 75-166-37-45.hlrn.qwest.net ([75.166.37.45]:51538 helo=pokyo.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 1f5xCc-001fH3-7i; Tue, 10 Apr 2018 12:37:06 -0500 From: Tom Tromey <tom@tromey.com> To: gdb-patches@sourceware.org Cc: Tom Tromey <tom@tromey.com> Subject: [RFA] Clear entire "location" in value constructor Date: Tue, 10 Apr 2018 11:37:04 -0600 Message-Id: <20180410173704.21702-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1f5xCc-001fH3-7i X-Source-Sender: 75-166-37-45.hlrn.qwest.net (pokyo.Home) [75.166.37.45]:51538 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes |
Commit Message
Tom Tromey
April 10, 2018, 5:37 p.m. UTC
My recent change to allocate values with "new" may have introduced a small bug. In particular, the previous code allocated with XCNEW, but the new code only clears a part of the "location" field in the constructor. I didn't try very hard to actually trigger a bug here, the problem remains theoretical. This patch changes the constructor to clear the entire "location". Regression tested by the buildbot. 2018-04-10 Tom Tromey <tom@tromey.com> * value.c (value::value): Clear "location". --- gdb/ChangeLog | 4 ++++ gdb/value.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)
Comments
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
Tom> 2018-04-10 Tom Tromey <tom@tromey.com>
Tom> * value.c (value::value): Clear "location".
Ping.
Tom
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes: >>>>> "Tom" == Tom Tromey <tom@tromey.com> writes: Tom> 2018-04-10 Tom Tromey <tom@tromey.com> Tom> * value.c (value::value): Clear "location". Tom> Ping. Ping. Just FYI, this one is borderline obvious. Tom
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes: >>>>> "Tom" == Tom Tromey <tom@tromey.com> writes: >>>>> "Tom" == Tom Tromey <tom@tromey.com> writes: Tom> 2018-04-10 Tom Tromey <tom@tromey.com> Tom> * value.c (value::value): Clear "location". Tom> Ping. Tom> Ping. Just FYI, this one is borderline obvious. Ping again. Maybe this should use {} instead of memset, what do you think? Tom
On 2018-04-10 13:37, Tom Tromey wrote: > My recent change to allocate values with "new" may have introduced a > small bug. In particular, the previous code allocated with XCNEW, but > the new code only clears a part of the "location" field in the > constructor. I didn't try very hard to actually trigger a bug here, > the problem remains theoretical. > > This patch changes the constructor to clear the entire "location". > > Regression tested by the buildbot. > > 2018-04-10 Tom Tromey <tom@tromey.com> > > * value.c (value::value): Clear "location". > --- > gdb/ChangeLog | 4 ++++ > gdb/value.c | 2 +- > 2 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/gdb/ChangeLog b/gdb/ChangeLog > index d46ecdd120..8cc1486c87 100644 > --- a/gdb/ChangeLog > +++ b/gdb/ChangeLog > @@ -1,3 +1,7 @@ > +2018-04-10 Tom Tromey <tom@tromey.com> > + > + * value.c (value::value): Clear "location". > + > 2018-04-10 Pedro Alves <palves@redhat.com> > > * gdbthread.h (finish_thread_state_cleanup): Delete declaration. > diff --git a/gdb/value.c b/gdb/value.c > index 12aa2b8bb4..64e3eaca22 100644 > --- a/gdb/value.c > +++ b/gdb/value.c > @@ -180,7 +180,7 @@ struct value > type (type_), > enclosing_type (type_) > { > - location.address = 0; > + memset (&location, 0, sizeof (location)); > } > > ~value () Ah, I stumbled upon that code recently and wondered why only location.address was set. Either memset or {} is fine with me. Simon
>>>>> "Simon" == Simon Marchi <simon.marchi@polymtl.ca> writes:
Simon> Ah, I stumbled upon that code recently and wondered why only
Simon> location.address was set. Either memset or {} is fine with me.
Thanks. I think I will change it to {}, since that seems cleaner.
Tom
On 05/25/2018 08:49 PM, Tom Tromey wrote: >>>>>> "Simon" == Simon Marchi <simon.marchi@polymtl.ca> writes: > > Simon> Ah, I stumbled upon that code recently and wondered why only > Simon> location.address was set. Either memset or {} is fine with me. Note that this is a union. > > Thanks. I think I will change it to {}, since that seems cleaner. Note that {} has the same effect as only setting the first field of the union with Clang, so it's a nop patch. It shouldn't really matter -- we're only supposed to access the active member anyway. Thanks, Pedro Alves
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d46ecdd120..8cc1486c87 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2018-04-10 Tom Tromey <tom@tromey.com> + + * value.c (value::value): Clear "location". + 2018-04-10 Pedro Alves <palves@redhat.com> * gdbthread.h (finish_thread_state_cleanup): Delete declaration. diff --git a/gdb/value.c b/gdb/value.c index 12aa2b8bb4..64e3eaca22 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -180,7 +180,7 @@ struct value type (type_), enclosing_type (type_) { - location.address = 0; + memset (&location, 0, sizeof (location)); } ~value ()