beast@gnome.org
[Top] [All Lists]

Re: alignment bug in birnetcdefs.h

Subject: Re: alignment bug in birnetcdefs.h
From: Stefan Westerfeld
Date: Tue, 11 Mar 2008 01:29:52 +0000
   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
_______________________________________________
beast mailing list
beast@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/beast

<Prev in Thread] Current Thread [Next in Thread>
  • Re: alignment bug in birnetcdefs.h, Stefan Westerfeld <=