bizarre restart bug: calling arduino ninjas.

My guess would be that you're running out of RAM, and that this is causing your stack (including return addresses) to be overwritten (possibly with 0's), and so when some function returns, it's jumping back to the start of your program (address 0). Or that running out of RAM is causing some other strange failure mode that creates the behavior you're seeing. Can you temporarily comment out any variables / lookup tables / strings in your code? Or use smaller data types for anything?