public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "bugdal at aerifal dot cx" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug nptl/16549] pthread_cond_wait and pthread_cond_timedwait do not suspend the calling thread
Date: Wed, 12 Feb 2014 17:18:00 -0000	[thread overview]
Message-ID: <bug-16549-131-Ohk5ek5t6G@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-16549-131@http.sourceware.org/bugzilla/>

http://sourceware.org/bugzilla/show_bug.cgi?id=16549

--- Comment #19 from Rich Felker <bugdal at aerifal dot cx> ---
On Wed, Feb 12, 2014 at 11:34:49AM +0000, vinxxe at gmail dot com wrote:
> the problem is: imagine I have to pack my types to save some memory

This is a fallacy. Unless you have a very large number of objects, the
amount of supporting code bloat to access misaligned objects is orders
of magnitude larger than what you save. Pthread synchronization
objects are also sufficiently large in themselves that they're going
to dominate any "waste" from padding. Moreover, if you just order your
struct members correctly (approximately: from largest to smallest)
you'll ensure that there is little or no padding.

> where is written that a pthread_cond_t variable must be 4 byte aligned?

Nowhere. On a C11 compiler, _Alignof could tell you this, but
otherwise the alignment requirement is not a documented aspect of the
interface because it can vary by target and you're supposed to be
relying on the compiler to align it correctly.

> I'm just talking about this, a way to avoid or to earlier detect such kind of
> errors

Unless you can prove the member in question is aligned, you can simply
never apply the & operator to any member of a packed structure. The
best way to avoid doing this is not using packed structures at all.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


  parent reply	other threads:[~2014-02-12 17:18 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-10 13:28 [Bug nptl/16549] New: " vinxxe at gmail dot com
2014-02-10 13:29 ` [Bug nptl/16549] " vinxxe at gmail dot com
2014-02-10 13:33 ` schwab@linux-m68k.org
2014-02-10 13:38 ` vinxxe at gmail dot com
2014-02-10 13:43 ` neleai at seznam dot cz
2014-02-10 13:45 ` jakub at redhat dot com
2014-02-10 13:46 ` vinxxe at gmail dot com
2014-02-11 17:50 ` bugdal at aerifal dot cx
2014-02-11 17:53 ` bugdal at aerifal dot cx
2014-02-11 18:54 ` vinxxe at gmail dot com
2014-02-12  9:24 ` vinxxe at gmail dot com
2014-02-12  9:35 ` schwab@linux-m68k.org
2014-02-12  9:43 ` vinxxe at gmail dot com
2014-02-12  9:48 ` jakub at redhat dot com
2014-02-12  9:51 ` vinxxe at gmail dot com
2014-02-12 10:01 ` schwab@linux-m68k.org
2014-02-12 10:09 ` vinxxe at gmail dot com
2014-02-12 10:44 ` schwab@linux-m68k.org
2014-02-12 11:34 ` vinxxe at gmail dot com
2014-02-12 17:10 ` bugdal at aerifal dot cx
2014-02-12 17:18 ` bugdal at aerifal dot cx [this message]
2014-02-12 17:25 ` vinxxe at gmail dot com
2014-02-12 17:42 ` vinxxe at gmail dot com
2014-06-13  8:41 ` fweimer at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-16549-131-Ohk5ek5t6G@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).