Re: alignment bug in birnetcdefs.h



   Hi!

Thank, Tim has implemeted your bugfix idea.

   Cu... Stefan

On Sat, Feb 09, 2008 at 03:29:58PM +0100, Sam Hocevar wrote:
>    birnetcdefs.h has the following declaration:
> 
> typedef union {
>   void       *cond_pointer;
>   BirnetUInt8 cond_dummy[MAX (8, BIRNET_SIZEOF_PTH_COND_T)];
> } BirnetCond;
> 
>    On 32-bit systems, this union is 32-bit aligned. The problem
> is that it is cast to a pthread_cond_t* pointer, for instance in
> birnetthreadimpl.cc, yet there is no knowledge about the pthread_cond_t
> alignment requirements. It causes crashes for instance on the sparc
> platform where pthread_cond_t has 64-bit members and thus requires
> 64-bit alignment.
> 
>    I suggest this simple solution. It may waste a few bytes on some
> platforms, but that is certainly negligible:
> 
> typedef union {
>   void         *cond_pointer;
>   BirnetUInt8   cond_dummy[MAX (8, BIRNET_SIZEOF_PTH_COND_T)];
>   long long int align;
> } BirnetCond;
> 
>    I of course suggest doing the same to BirnetMutex.
-- 
Stefan Westerfeld, Hamburg/Germany, http://space.twc.de/~stefan


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]