Ethereal-dev: Re: [Ethereal-dev] Bug causing ethereal to crash

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <gharris@xxxxxxxxx>
Date: Mon, 7 Jun 2004 22:51:10 -0700
On Thu, Jun 03, 2004 at 09:53:04PM -0400, J. Scott Berg wrote:
> I think I've tracked down the cause.  I think that
> the SLAB_ALLOC/SLAB_FREE macros break ANSI strict aliasing rules.  The
> problem is that the memory at the beginning of an item in the list is
> accessed both through a "struct _freed_item*" and a "field_info *".
> This means that the complier is free to re-order those accesses, and
> some versions of gcc (gcc-3.4 in my case) do (I verified that it was
> in fact re-ordering that access).
> 
> configuring with CFLAGS='-g -O2 -fno-strict-aliasing' makes it work.

...with GCC, at least.  GCC isn't the only compiler used to compile
Ethereal, however, so that might not be sufficient of other compilers
assume that the objects aren't the same and that accesses to them can
therefore be reordered.

Are those rules C89'isms or C99'isms?  If they're C99-isms, is there
anything in C99 to tell the compiler that the two pointers really *do*
point to the same object?  (E.g., a keyword - from some stuff I found,
it looks as if "restrict" is *not* what we want, as it allows *more*
optimizations - or use of a union.)