koka-lang / madoko

Madoko is a fast markdown processor for high quality academic and technical articles

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stack-size crash in runLatex

RustanLeino opened this issue · comments

I have a Madoko-authored book manuscript that's over 450 printed pages (over 22,000 lines of Madoko source). Lately (perhaps because of my growing document or perhaps because of my upgrade to Madoko version 1.2.3), I'm no longer able to generate PDF. When I try, I get the following crash in findLines in (the Koka generated) runLatex.js:

/usr/local/lib/node_modules/madoko/lib/runLatex.js:122
  return $std_core.map_3(
    offsets,
    function(ofs  /* int */ ) {
      var total = { value: 0 };
      var current = { value: 1 };
      $std_core.foreachUntil(
        slens,
        function(len  /* int */ ) {
          ((total).value = ((((total).value) + len)|0));
          var _x0 = ((total).value) > ofs;
          if (_x0) {
            return $std_core.Just(((current).value));
          } else {
            $std_core._unit_;
          }
          ((current).value = ((((current).value) + 1)|0));
          return $std_core.Nothing;
        });
      return ((current).value);
    });
                                                                                                                                                           ^

RangeError: Maximum call stack size exceeded
    at /usr/local/lib/node_modules/madoko/lib/runLatex.js:122:156
    at foreachUntil (/usr/local/lib/node_modules/madoko/lib/std_core.js:1786:15)
    at foreachUntil (/usr/local/lib/node_modules/madoko/lib/std_core.js:1787:28)
    at foreachUntil (/usr/local/lib/node_modules/madoko/lib/std_core.js:1787:28)
    at foreachUntil (/usr/local/lib/node_modules/madoko/lib/std_core.js:1787:28)
    at foreachUntil (/usr/local/lib/node_modules/madoko/lib/std_core.js:1787:28)
    at foreachUntil (/usr/local/lib/node_modules/madoko/lib/std_core.js:1787:28)
    at foreachUntil (/usr/local/lib/node_modules/madoko/lib/std_core.js:1787:28)
    at foreachUntil (/usr/local/lib/node_modules/madoko/lib/std_core.js:1787:28)
    at foreachUntil (/usr/local/lib/node_modules/madoko/lib/std_core.js:1787:28)

(For readability, I inserted the line breaks in code above.)