Current-Users archive

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

Re: Cross-building on MacOS X/lint failure

On Mon, Dec 01, 2008 at 03:23:05PM -0500, Ken Hornstein wrote:
> When the cross-platform lint is run on libc, it gets a LOT of fatal
> errors from various source code files.  Originally I wasn't in the
> mood to figure out what was going wrong, so I changed the libc Makefile
> to exclude the particular errors lint was reporting (I did look at the
> source code lint complained about, and the errors seemed bogus to me).
> But I got to a point where lint core dumped, and decided to take a
> closer look.
> I tracked down the source of that problem to the following statement in
> src/usr.bin/xlint/lint1/tree.c: (function getnnode(), line 345)
>               *n->tn_val = sym->s_value;

Does sym happen to be pointing at (or overlapping) n->tn_sym?  
tn_val is part of a union, which happens to also have a sym_t member.

> What ends up happening is that n->tn_val get corrupted during that
> assignment and eventually n->tn_val is deferenced later on, which
> causes a SIGBUS.
> This, however, makes no sense to me.  This assignment looks perfectly legal,
> and it shouldn't be corrupting the pointer value.  I replace this with:
>               memcpy(n->tn_val, &sym->s_value, sizeof(val_t));
> And I got the same exact corrupted pointer.  Just for the hell of it,
> I replaced this with a loop copying the memory byte by byte, and it worked.

Did your loop use a temporary variable for the value of &sym->s_value?
If sym overlaps with tn_val that would make things work since you'd have a 
consistent view of the value of that pointer.


Home | Main Index | Thread Index | Old Index