title: Scilab compilation "cannot allocate this quantity of memory"
body: <p>I am facing issues with memory allocation in Scilab after compiling.</p>
  
  <p>I am compiling on a Red Hat on ppc64 (POWER8). Stack limits are already set to unlimited (<code>ulimit -s unlimited</code>). The <code>./configure</code> script (with several options I am not showing here) runs successfully, but the <code>make all</code> fails and stops. When it stops, it is stuck at the Scilab command prompt with this message:</p>
  
  <pre><code>./bin/scilab-cli -ns -noatomsautoload -f modules/functions/scripts/buildmacros/buildmacros.sce
  stacksize(5000000);
                     !--error 10001
  stacksize: Cannot allocate memory.
  %s: Cannot allocate this quantity of memory.
  
  at line      27 of exec file called by :
  exec('modules/functions/scripts/buildmacros/buildmacros.sce',-1)
  
  --&gt;
  </code></pre>
  
  <p>I have investigated a bit, and that error message seems to be called of course at line <code>00027</code> in <code>buildmatros.sce</code>, where the function <code>stacksize(5000000)</code> is called.</p>
  
  <p>This function is defined in:</p>
  
  <pre><code> scilab-5.5.1/modules/core/sci_gateway/c/sci_stacksize.c
  </code></pre>
  
  <p>I found a version of the file at this page: <a href="http://doxygen.scilab.org/master_wg/d5/dfb/sci__stacksize_8c_source.html" rel="nofollow">http://doxygen.scilab.org/master_wg/d5/dfb/sci__stacksize_8c_source.html</a>.
  The condition that is FALSE and that triggers the message seems to me to show up at line 00295.</p>
  
  <p>Inside that file, you see that error is displayed whenever the <code>stacksize</code> given as input is LARGER than what is returned by the method <code>get_max_memory_for_scilab_stack()</code> from the class:</p>
  
  <pre><code>scilab-5.5.1/modules/core/src/c/stackinfo.c
  </code></pre>
  
  <p>Again I found a version online at the following page:
  <a href="http://doxygen.scilab.org/master_wg/dd/dfb/stackinfo_8h.html#afbd65a57df45bed9445a7393a4558395" rel="nofollow">http://doxygen.scilab.org/master_wg/dd/dfb/stackinfo_8h.html#afbd65a57df45bed9445a7393a4558395</a>
  The Method is declared from line <code>109</code>.</p>
  
  <p>It seems to invoke a variable called <code>MAXLONG</code>, which is however NEVER explicitly declared! As you see, it is declared several times (line <code>00019</code>, <code>00035</code>, <code>00043</code>, <code>00050</code>), but all lines are commented! <em>[correction: the lines are NOT commented, it was my false understanding of # being a comment sign, but it's not]</em></p>
  
  <p>So my guess is: <code>MAXLONG</code> is not declared, so the function does not return a value (or it returns 0) and therefore the error message is triggered because the <code>stacksize</code> given as input is higher than 0 or <code>NULL</code> or <code>N/A</code>.</p>
  
  <p>My questions are then:</p>
  
  <ul>
  <li>Why are all lines commented where MAXLONG is defined?</li>
  <li>Where does MAXLONG originate from? Is it something passed from the kernel?</li>
  <li>How can I solve the problem?</li>
  </ul>
  
  <p>Thanks!</p>
  
  <p>PS - I tried to uncomment the line in <code>buildmacros</code>, and it compiled and installed without issues. However, when I started <code>scilab-cli</code>, it displayed the same message again. </p>
  
  <hr>
  
  <p>Edit after further investigation:</p>
  
  <p>After further investigation, I found out that what I thought were the comments are indeed instructions for the compiler... but I kept those errors of mine, so that the answer to my question is understandable.</p>
  
  <p>Here are my new points.</p>
  
  <p>In Scilab I noticed that by giving an input stacksize out of bounds, the same method <code>get_max_memory_for_scilab_stack()</code> is invoked, to get the upper bound. The lower bound I've seen it's defined by default.</p>
  
  <pre><code>--&gt;stacksize(1)
               !--error 1504
  stacksize: Out of bounds value. Not in [180000,268435454].
  </code></pre>
  
  <p>Also the stacksize used seems fine:</p>
  
  <pre><code>--&gt;stacksize()
   ans  =
  
      7999994.    332.
  </code></pre>
  
  <p>However, when trying to give such value an input inbetween, it fails.</p>
  
  <pre><code>--&gt;stacksize(1)
               !--error 1504
  stacksize: Out of bounds value. Not in [180000,268435454].
  </code></pre>