lua-users home
lua-l archive

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



On 31 Jul 2006, at 17:15, Archie Maskill wrote:

Hello there -

There appears to be a problem when running 'sieve.lua', the test
script that comes with the Lua source code.

I'm running it under uClinux on an embedded device with an ARM
processor and no MMU.

The script prints all prime numbers up to 1000, and consistently gets
as far as "359" before crashing with a SIGSEGV.  The script does run
for longer when I increase the lua executable's stack size using the
uClinux tool 'flthdr'.  I increased it from 32768 to 65536, and it
consistently reached the prime "787" before segfaulting.

LUAI_MAXCCALLS, _not_ LUAI_MAXCALLS, controls how much fun Lua likes to have recursing into C functions. LUAI_MAXCSTACK is pretty much a red herring (unless your C functions push hundreds and hundreds of values onto the Lua stack).

Try changing that. I'm still trying to work out if the coroutine library respects it.

Note that even if you do change LUAI_MAXCCALLS Lua can't guarantee that you won't run out of C stack, because it can't know how big any of the C stack frames are. It's up to you, you the person writing the linker script, to make sure that Lua has enough C stack for it, but this is pretty routine for the embedded world.


By the way, a segfault is particularly bad on an embedded system with
no MMU because it indicates random memory, possibly belonging to
another process, is being overwritten.

Multiprocessing without an MMU? It was madness back in 1990 on RiscOS, and it still is now.

drj