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

Bug#670578: Crashes caused by gnunet bug



Hello,

I've spent some time looking at it today (after Christian kindly 
provided access to gnunet's sparc buildbot and detailed instructions 
on how to reproduce the bug), and by now I'm pretty certain that the 
unaligned memory accesses are caused by a bug in gnunet. At first 
glance it looks like the GNUNET_HashCode struct should always be 
word-aligned, however closer inspection reveals that its definition 
(in src/include/gnunet_common.h) looks like this:

GNUNET_NETWORK_STRUCT_BEGIN

[...]

/**
 * @brief 512-bit hashcode
 */
struct GNUNET_HashCode
{
  uint32_t bits[512 / 8 / sizeof (uint32_t)];   /* = 16 */
};

[...]

GNUNET_NETWORK_STRUCT_END

The preprocessed source indicates that these header and footer macros 
expand into

#pragma pack(push)
#pragma pack(1)

and

#pragma pack(pop)

respectively. This essentially eliminates the alignment requirements 
for members of this struct, so compiler is fully within its right to 
place it at 2-bytes boundary, which eventually leads to an unaligned 
memory access resulting in a crash. 

Best regards,
-- 
Jurij Smakov                                           jurij@wooyd.org
Key: http://www.wooyd.org/pgpkey/                      KeyID: C99E03CC


Reply to: