I could not find anything applicable for me on stack size in the documentation. After some googling I increased the stack size in the tcsh, after which the program compiled fine. Thanks for the help! Now, to me the beautiful task of digging up the culprit in our code, and making it a `var'.
Maybe it is something to put in the docs. I wrote a tiny bit below, after a bit of ranting. Feel free to copy and adapt ( Yes, you have my permission to use and modify the text I shamelessly stole from e-mails you wrote yourself ;-) )
Hopefully I am not too patronizing, but in my opinion, URL:http://www.gnu-pascal.de/todo.html does not give clear directions. It took me some time to find the link URL:http://www.gnu-pascal.de/gpc/Compiler-Crashes.html, which was hidden in `where to get support'. This is actually the page I expected to find following the URL provided in the error message. It might be an improvement to direct the user to that page. On that page, links to the known bugs, planned features, fixed bugs and `where to get support' could help a user solving a compiler crash.
Now for the snippet of documentation:
<Header>Gpc crashed... now what?</Header>
If the compiler crashes with the following error
gpc: Internal error: Segmentation fault (program gpc1) Please submit a full bug report. See URL:http://www.gnu-pascal.de/todo.html for instructions. gpc1: gpc exited with status 1
<FIXME: insert a list of other possible causes, like a link to the known bugs>
a possible cause may be that the operating system provides a too small stack size. This can be verified in the following way: increase the stack size and try to compile the program again.
On Unix-like systems, the stack size can be increased in the shell settings (bash: ulimit; csh: limit; syscall: setrlimit(2)).
For DJGPP (MS-DOS) platforms, see URL:http://www.gnu-pascal.de/gpc/Stack-size.html
A large stack size can be required if large arrays are passed as value. Try passing them as `var' parameters (if you want to protect them from modification make them `protected').
<FIXME: insert other causes of large stack usage.>
Regards, Marten Jan
On Tuesday 11 May 2004 03:44, you wrote:
Frank Heckenbach wrote:
Waldek Hebisch wrote:
It looks that you are passing large arrays by value. Such arrays may cause problems at runtime due to limit on stack usage (by default 10Mb on Linux) -- arguments are passed by value and consume stack space. Unfortunatly, such array consume even more space in the compiler.
But only if they are initialized field by field or something like that, shouldn't they?
Am I missing something? AFAICS, Marten didn't show any actual code. The following program compiles fine for me (but crashes with stack overflow when trying to run it).
program Foo;
type a = array [1 .. 100000000] of Integer;
var v: a;
procedure p (v: a); begin end;
begin p (v) end.
Compiles fine with 3.2.3. Crashes with 3.3.3 and 3.4.0. With 20Gb stack limit compiles fine. The following compiles with 2.95.3 but crashes with 3.x:
program foo(output); type ta = string(20000000); var a, b : ta; procedure bar(v : ta); begin write(v) end; procedure baz(u, w : ta); begin write(u); bar(w) end; begin baz(a,b); writeln end .
If I increase stack limit then 3.x works OK.