Ethereal-dev: Re: [Ethereal-dev] Core dump in lemon on grammar.lemon

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

From: Guy Harris <guy@xxxxxxxxxx>
Date: Wed, 14 Feb 2001 18:57:12 -0800 (PST)
> Just trying to build the latest nightly-build (ethereal-2001-02-14) on
> *Alpha* 
> running RH Linux 6.2. 
> It dumps core on a segfault with lemon trying to make
> ./epan/dfilter/grammar.c
> Attached is the backtrace from the core :-
> 
> #0  msort (list=0x1201179b0 "P\216\021 \001", next=0x1201179f0, 
>     cmp=0x120009560 <Configcmp>) at lemon.c:1466
> 1466	    list = NEXT(list);

Take a look at line 1384 of "lemon.c".

Anybody used to working with 64-bit processors is likely to be a bit
disturbed by that line of code:

	#define NEXT(A) (*(char**)(((int)A)+offset))

"Thou Shalt Not Assume That An 'int' Is Large Enough To Hold A Pointer."

What's odd is that "NEXT()" always appears to be passed a "char *" as an
argument, so that the cast to "int" shouldn't be necessary.  Replacing
it with a cast to "char *", rather than removing it, might be the right
thing to do, though.

There are some more places where he's casting pointers to "int" in order
to do arithmetic on them; those should probably also be changed to cast
to "char *" (and if a compiler whines, cast first to "void *" and then
to "char *"; do *NOT* assume that you can do pointer arithmetic on "void
*"s, that's a GCCism).