Current-Users archive

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

Cross-building on MacOS X/lint failure



Has anyone tried cross-building NetBSD on MacOS X recently?

I was attempting to cross-build NetBSD 4.0.1 on my MacOS X box for
a evbarm system (that's a whole OTHER story) running 10.5.5, with the
latest version of X Code.  The problem I'm experiencing seems to stem
from the cross-platform version of lint.

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;

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.
Well, it worked well enough to make it so it didn't core dump any more.
The fact that lint still reports tons of errors that it presumably doesn't
under normal circumstances makes me think there is still something
fundamentally wrong here.  I eventually gave up and simply built things
with NOLINT=1.

The one thing I did notice was that instead of using malloc(), lint does
it's own memory management by using an allocator based on mmap().  I am
wondering if this isn't quite portable to MacOS X.

--Ken


Home | Main Index | Thread Index | Old Index