alignment bug in birnetcdefs.h
- From: Sam Hocevar <sam zoy org>
 
- To: Beast List <beast gnome org>
 
- Subject: alignment bug in birnetcdefs.h
 
- Date: Sat, 9 Feb 2008 15:29:58 +0100
 
   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.
Cheers,
-- 
Sam.
[Date Prev][Date Next]   [Thread Prev][Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]