This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug nptl/16549] pthread_cond_wait and pthread_cond_timedwait do not suspend the calling thread


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

--- Comment #21 from vinxxe at gmail dot com ---
I agree with you, again. 
Unfortunately things are not so easy. I never wrote the incriminate code. The
code was written by someone on a very old hw with an Mx rtos. Then someone else
ported this software under Linux. Then they gave to me the work of making
things work (because as you can easily imagine nothing worked). And in the
software the pragma pack is written in one header file included by every source
file, so you cannot say, at first sight, that the compiler is packing
everything. This is the very nasty story. I never had such kind of problem
before because, like you suggest, I never use the nasty compiler tools. 
BTW thank you again for your time 

(In reply to Rich Felker from comment #19)
> 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]