strange jit.gen loop behavior

    Sep 15 2012 | 4:53 pm
    I have a strange thing happening inside a jit.gen loop:
    There is a counter on my macbbok always counting to 50001, although the condition is n What am I missing here ?!?
    Thank you very much for any help !

    • Sep 17 2012 | 2:08 am
      Hi there,
      What's happened here is that you've hit the runaway loop trap. There's a limitation in jit.gen that loops can only repeat up to 50001 times. To work around this currently you could duplicate the loop four times, but this might not always work. I've logged a feature request to make this loop limit configurable.
      Full explanation: Gen generates machine code under the hood, which requires some extra precaution. For example, an infinite (or extremely large) loop could effectively lock up the system thread it is running in, which could make Max appear to have frozen. To prevent this happening, a loop will always exit after a certain number of iterations, which for jit.gen is currently set to 50001.
      Hope that helps,
    • Dec 28 2013 | 7:04 pm
      Hi Graham, is there any news regarding the possibility to set an arbitrary loop limit in gen? Thank you.