From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10014 invoked by alias); 12 Feb 2014 17:18:14 -0000 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org Received: (qmail 9966 invoked by uid 55); 12 Feb 2014 17:18:11 -0000 From: "bugdal at aerifal dot cx" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: nptl X-Bugzilla-Version: 2.12 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bugdal at aerifal dot cx X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-02/txt/msg00427.txt.bz2 http://sourceware.org/bugzilla/show_bug.cgi?id=16549 --- Comment #19 from Rich Felker --- 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.