Hello
This is the smallest program which displays the bug
program bug;
var s:string[255]='';
begin s:=s+'a'; s:=s+'b'; end.
It works fine apparently. But by stepping with a debugger, I see that after each string concatenation the stack is increased by 16 bytes. No harm in usual programs since the stack is released at each exit of procedure by something like mov %ebp,%esp But in a procedure which was computing 80*480 bytes and concatenating them to strings, the increase in stack size by 16*80*480=614400 bytes overflowed the default djgpp stack size of 512k, producing weird crashes. As a workaround I increased the stack size of course, but the bug should be solved. The bug is present with or without optimization options, both on my work computer: djgpp v2.03, gpc-20010623 based on gcc-2.95.3, binutils 2.11.2, W98se dos box, and on my home computer djgpp v2.03, gpc-20010315 based on gcc-2.95.2, binutils 2.9.5.1, bare dos 6.23 The first step would be to try on a linux machine to see if it is a problem of gpc or djgpp. I have none at hand presentlly.
Hope this helps
Maurice
Maurice Lombardi wrote:
This is the smallest program which displays the bug
program bug;
var s:string[255]='';
begin s:=s+'a'; s:=s+'b'; end.
It works fine apparently. But by stepping with a debugger, I see that after each string concatenation the stack is increased by 16 bytes. No harm in usual programs since the stack is released at each exit of procedure
Yes, it's a known problem (GPC allocates a temp variable for the concatenation, but does it on a procedure scope, rather than locally in the expression). Has caused me and others some problems as well. I hope Peter can fix it sometime ... :-/
Frank