2
votes

I am facing issues with memory allocation in Scilab after compiling.

I am compiling on a Red Hat on ppc64 (POWER8). Stack limits are already set to unlimited (ulimit -s unlimited). The ./configure script (with several options I am not showing here) runs successfully, but the make all fails and stops. When it stops, it is stuck at the Scilab command prompt with this message:

./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)

-->

I have investigated a bit, and that error message seems to be called of course at line 00027 in buildmatros.sce, where the function stacksize(5000000) is called.

This function is defined in:

 scilab-5.5.1/modules/core/sci_gateway/c/sci_stacksize.c

I found a version of the file at this page: http://doxygen.scilab.org/master_wg/d5/dfb/sci__stacksize_8c_source.html. The condition that is FALSE and that triggers the message seems to me to show up at line 00295.

Inside that file, you see that error is displayed whenever the stacksize given as input is LARGER than what is returned by the method get_max_memory_for_scilab_stack() from the class:

scilab-5.5.1/modules/core/src/c/stackinfo.c

Again I found a version online at the following page: http://doxygen.scilab.org/master_wg/dd/dfb/stackinfo_8h.html#afbd65a57df45bed9445a7393a4558395 The Method is declared from line 109.

It seems to invoke a variable called MAXLONG, which is however NEVER explicitly declared! As you see, it is declared several times (line 00019, 00035, 00043, 00050), but all lines are commented! [correction: the lines are NOT commented, it was my false understanding of # being a comment sign, but it's not]

So my guess is: MAXLONG is not declared, so the function does not return a value (or it returns 0) and therefore the error message is triggered because the stacksize given as input is higher than 0 or NULL or N/A.

My questions are then:

  • Why are all lines commented where MAXLONG is defined?
  • Where does MAXLONG originate from? Is it something passed from the kernel?
  • How can I solve the problem?

Thanks!

PS - I tried to uncomment the line in buildmacros, and it compiled and installed without issues. However, when I started scilab-cli, it displayed the same message again.


Edit after further investigation:

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.

Here are my new points.

In Scilab I noticed that by giving an input stacksize out of bounds, the same method get_max_memory_for_scilab_stack() is invoked, to get the upper bound. The lower bound I've seen it's defined by default.

-->stacksize(1)
             !--error 1504
stacksize: Out of bounds value. Not in [180000,268435454].

Also the stacksize used seems fine:

-->stacksize()
 ans  =

    7999994.    332.

However, when trying to give such value an input inbetween, it fails.

-->stacksize(1)
             !--error 1504
stacksize: Out of bounds value. Not in [180000,268435454].
1
It is defined in: stackinfo.c line 00035 #define MAXLONG LONG_MAX, which should be 2 GB, so max should be 2GB/8 or 256M.Klas Lindbäck

1 Answers

1
votes

It seems to invoke a variable called MAXLONG

It's not a variable, but a pre-processor macro.

Why are all lines commented where MAXLONG is defined?

You should ask that from the person who commented the lines. They're not commented in scilab-5.5.1 that's online.

Where does MAXLONG originate from? Is it something passed from the kernel?

It's defined in the file scilab-5.5.1/modules/core/src/c/stackinfo.c. It's defined to the same value as LONG_MAX which is defined by the standard c library (<limits.h> header). If the macro is not supplied by the standard library, then it's defined to some other, platform specific value.

How can I solve the problem?

If your problem originates from the lack of definition for MAXLONG, then you must define it. One way going about it is to uncomment the lines that define it. Or re-download the original sources since yours don't appear to match with the official ones.