> Andy Ross wrote:
> > Works for me, obviously.  Stack trace?
>
> Not yet, I haven't looked into that part yet (at first I was under the
> impression that this was C(++) code until I discovered I was already
> running a script :-)
>
> I think it might be a big-/little endian problem.

There *is* an endian dependence in Nasal.  There's a comment at the
top of nasal.h.  Basically, Nasal's pass-by-value "naRef" type stores
either a pointer to a garbage-collected object, *or* a double.  It
tells the difference by putting a magic number in the unused half of
the double.  This value is crafted such that it makes the double look
like a NaN, which can never result from a valid computation.  But to
do that, it needs to live in the "top" half of the double, which
depends on the endianness of the processor.  It is correct as written
for little-endian 32 bit and all 64 bit systems.  Big-endian 32 bit
architectures like MIPS32 should swap the order of components in the
naRef structure.

In some circumstance (albeit not FlightGear), this can be a terrible
security hole -- an attacker could create a fancy number with the
right values in the bottom bits and cause the interpreter to derefence
memory pointed to by the top half.  But I don't think this is what is
causing your problem.  The likelihood of actually seeing such a number
in practice is almoze zero (maybe exactly zero in this case -- the
test.nas script uses only integer math).  And in such a case, of
course, you are exceedingly unlikely to hit valid memory; you'd almost
certainly just crash.

Anyway, try setting the NASAL_BIG_ENDIAN_32BIT #define at the top of
nasal.h.  It probably won't help, but it's the Right Thing to do.  We
need to detect this automatically.  SimGear doesn't have an existing
endianness test; is there a semi-standard autoconf way of doing this?
At worst, we could just build a big tree of #if's for every
architecture we support.  Ugly, though.

But I have a few bugfixes queued up.  I *think* all of them should
have been deterministic across architectures.  But you never know.
Give me a few hours to put together another code drop.

Andy



_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to