public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Initialize pad outside the conditional to prevent uninitialized data warnings.
@ 2018-06-25 14:19 Patsy Franklin
  2018-06-25 14:39 ` Florian Weimer
  0 siblings, 1 reply; 4+ messages in thread
From: Patsy Franklin @ 2018-06-25 14:19 UTC (permalink / raw)
  To: GNU C Library

[-- Attachment #1: Type: text/plain, Size: 441 bytes --]

Notes:

In sem_open.c,  pad was only initialized when __HAVE_64B_ATOMICS was
not true causing valgrind to warn about uninitialized data on some
arches.  This patch moves the initialization of pad outside of the
conditional.

Prior to this change, valgrind warned about unitialized bytes on
ppc64, ppc64le, s390x, and aarch64.

Tested on ppc64le with no regressions.   Used valgrind to confirm that
the uninitialized bytes warning was fixed.

[-- Attachment #2: sem_open.patch --]
[-- Type: text/x-patch, Size: 800 bytes --]

2018-06-22  Patsy Franklin  <pfrankli@redhat.com>

	* nptl/sem_open.c [!__HAVE_64B_ATOMICS] (sem_open): Don't update pad.
	(sem_open): Set sem.newsem.pad to zero for valgrind.

diff --git a/nptl/sem_open.c b/nptl/sem_open.c
index 1d7f142134..c5389f6873 100644
--- a/nptl/sem_open.c
+++ b/nptl/sem_open.c
@@ -215,10 +215,11 @@ sem_open (const char *name, int oflag, ...)
       sem.newsem.data = value;
 #else
       sem.newsem.value = value << SEM_VALUE_SHIFT;
-      /* pad is used as a mutex on pre-v9 sparc and ignored otherwise.  */
-      sem.newsem.pad = 0;
       sem.newsem.nwaiters = 0;
 #endif
+      /* pad is used as a mutex on pre-v9 sparc and ignored otherwise.  */
+      sem.newsem.pad = 0;
+
       /* This always is a shared semaphore.  */
       sem.newsem.private = FUTEX_SHARED;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Initialize pad outside the conditional to prevent uninitialized data warnings.
  2018-06-25 14:19 [PATCH] Initialize pad outside the conditional to prevent uninitialized data warnings Patsy Franklin
@ 2018-06-25 14:39 ` Florian Weimer
  2018-06-25 17:16   ` Patsy Franklin
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Weimer @ 2018-06-25 14:39 UTC (permalink / raw)
  To: Patsy Franklin, GNU C Library

On 06/25/2018 04:18 PM, Patsy Franklin wrote:
> Prior to this change, valgrind warned about unitialized bytes on
> ppc64, ppc64le, s390x, and aarch64.

How come that valgrind warns when it's supposed to be uninitialized 
padding?  Do you have a valgrind trace (preferably with debugging symbols)?

Thanks.
Florian

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Initialize pad outside the conditional to prevent uninitialized data warnings.
  2018-06-25 14:39 ` Florian Weimer
@ 2018-06-25 17:16   ` Patsy Franklin
  2018-06-25 17:18     ` Florian Weimer
  0 siblings, 1 reply; 4+ messages in thread
From: Patsy Franklin @ 2018-06-25 17:16 UTC (permalink / raw)
  To: Florian Weimer; +Cc: GNU C Library

Hi Florian,

On Mon, Jun 25, 2018 at 10:39 AM, Florian Weimer <fweimer@redhat.com> wrote:
> On 06/25/2018 04:18 PM, Patsy Franklin wrote:
>>
>> Prior to this change, valgrind warned about unitialized bytes on
>> ppc64, ppc64le, s390x, and aarch64.
>
>
> How come that valgrind warns when it's supposed to be uninitialized padding?

The problem occurs when the partially initialized struct is written to
the file system.

I should have stated this in the original description.

Thanks,
Patsy

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Initialize pad outside the conditional to prevent uninitialized data warnings.
  2018-06-25 17:16   ` Patsy Franklin
@ 2018-06-25 17:18     ` Florian Weimer
  0 siblings, 0 replies; 4+ messages in thread
From: Florian Weimer @ 2018-06-25 17:18 UTC (permalink / raw)
  To: Patsy Franklin; +Cc: GNU C Library

On 06/25/2018 07:15 PM, Patsy Franklin wrote:
> Hi Florian,
> 
> On Mon, Jun 25, 2018 at 10:39 AM, Florian Weimer <fweimer@redhat.com> wrote:
>> On 06/25/2018 04:18 PM, Patsy Franklin wrote:
>>>
>>> Prior to this change, valgrind warned about unitialized bytes on
>>> ppc64, ppc64le, s390x, and aarch64.
>>
>>
>> How come that valgrind warns when it's supposed to be uninitialized padding?
> 
> The problem occurs when the partially initialized struct is written to
> the file system.
> 
> I should have stated this in the original description.

Looks okay to me if you put this into the commit message.

Thanks,
Florian

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-06-25 17:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-25 14:19 [PATCH] Initialize pad outside the conditional to prevent uninitialized data warnings Patsy Franklin
2018-06-25 14:39 ` Florian Weimer
2018-06-25 17:16   ` Patsy Franklin
2018-06-25 17:18     ` Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).