Hi, all.
I've been fighting a bug for a while, and when I stripped it down to its basics, I was surprised. My test program is appended.
The issue involves arrays of size > 255. When I use Ymax = Zmax = 250, the program runs fine. When I use Ymax = Zmax = 260, the portion of the program that runs in Main works fine, but the procedure stops at y = 7, z = 260 - the program hangs, with ^C ineffective.
I'm running a pentium 400 under Win98. I've had no trouble with this in small arrays, but 256 seems to be a divide of some sort.
Any suggestions appreciated. Toby
Toby Ewing Soil Scientist, Iowa State University
-------------------------------------------------------------------
Program TestLgArray;
Const Xmax = 25 ; {physical space - grid units} Ymax = 260; {physical space - grid units} Zmax = 260;
Type Compary = array[1..Ymax, 1..Zmax] of integer;
var Comp : Compary; x, y, z : integer;
{________________________________________________ } Procedure Zero;
var Comp : Compary; x, y, z : integer;
begin writeln('Procedure:'); readln; for y := 1 to Ymax do begin {zero the comp array} for z := 1 to Zmax do Comp[y,z] := 0; writeln('y=', y:3, ' z=', z:1); end; end; {________________________________________________ }
begin {Main Program} writeln('Main:'); readln; for y := 1 to Ymax do begin {zero the comp array} for z := 1 to Zmax do Comp[y,z] := 0; writeln('y=', y:3, ' z=', z:1); end; Zero; write(' done'); end.
On 26 Apr 00, at 12:48, Toby Ewing wrote:
Hi, all.
I've been fighting a bug for a while, and when I stripped it down to its basics, I was surprised. My test program is appended.
The issue involves arrays of size > 255. When I use Ymax = Zmax
= 250,
the program runs fine. When I use Ymax = Zmax = 260, the portion
of the
program that runs in Main works fine, but the procedure stops at y =
7,
z = 260 - the program hangs, with ^C ineffective.
I'm running a pentium 400 under Win98. I've had no trouble with
this in
small arrays, but 256 seems to be a divide of some sort.
[....]
What version of GPC are you running ? The program runs fine here (under NT 4.0, with the latest Mingw32 snapshot on agnes ('/home/chief/gpc-20000401-i386-mingw32msvc.....').
Best regards, The Chief -------- Dr. Abimbola A. Olowofoyeku (The African Chief) Author of: Chief's Installer Pro v5.22.1 for Win32 http://www.bigfoot.com/~African_Chief/chief32.htm Email: African_Chief@bigfoot.com
I have had similar problems when I used the DJGPP port of GPC, basicaly it was due pointer problem that was my fault, but programs ran fine when using the non DJGPP ports [just to utterly confuse me]. Hope that might be some help John Blakeney
Toby Ewing wrote:
Hi, all.
I've been fighting a bug for a while, and when I stripped it down to its basics, I was surprised. My test program is appended.
The issue involves arrays of size > 255. When I use Ymax = Zmax = 250, the program runs fine. When I use Ymax = Zmax = 260, the portion of the program that runs in Main works fine, but the procedure stops at y = 7, z = 260 - the program hangs, with ^C ineffective.
I'm running a pentium 400 under Win98. I've had no trouble with this in small arrays, but 256 seems to be a divide of some sort.
Any suggestions appreciated. Toby
Toby Ewing Soil Scientist, Iowa State University
Program TestLgArray;
Const Xmax = 25 ; {physical space - grid units} Ymax = 260; {physical space - grid units} Zmax = 260;
Type Compary = array[1..Ymax, 1..Zmax] of integer;
var Comp : Compary; x, y, z : integer;
{________________________________________________ } Procedure Zero;
var Comp : Compary; x, y, z : integer;
begin writeln('Procedure:'); readln; for y := 1 to Ymax do begin {zero the comp array} for z := 1 to Zmax do Comp[y,z] := 0; writeln('y=', y:3, ' z=', z:1); end; end; {________________________________________________ }
begin {Main Program} writeln('Main:'); readln; for y := 1 to Ymax do begin {zero the comp array} for z := 1 to Zmax do Comp[y,z] := 0; writeln('y=', y:3, ' z=', z:1); end; Zero; write(' done'); end.
John Blakeney a écrit :
I have had similar problems when I used the DJGPP port of GPC, basicaly it was due pointer problem that was my fault, but programs ran fine when using the non DJGPP ports [just to utterly confuse me]. Hope that might be some help John Blakeney
Besides pointers problems, which may be different on different systems due to the efficiency of that underlying system to catch invalid pointers, there is a difference between the Compary contained in main and the other contained in the procedure. The first being global is allocated in the heap, the second is allocated in the stack, so you may have a problem of stack overflow. The size of that array 256x256x4x2 = 512 kb is not very large, but you could have problems with the settings of your W98 / DOS box: look to properties / memory settings. In pure DOS djgpp you should stubedit your executable to check its stack size (by default it is only 256k or 512k depending on the version of djgpp and/or gpc I think), but I am not sure how it is allocated in a W98 DOS Box (stubedit works in a DOS box but I am not sure if its settings are valid in a W98 dos box or only apply when the executable is run under CWSDPMI (pure dos)). Anyhow a 512k setting for stack is not enough in your case. In contrast a global variable can use all DPMI memory + swap space available (as reported by typing go32-v2 at dos prompt).
Toby Ewing wrote:
Hi, all.
I've been fighting a bug for a while, and when I stripped it down to its basics, I was surprised. My test program is appended.
The issue involves arrays of size > 255. When I use Ymax = Zmax = 250, the program runs fine. When I use Ymax = Zmax = 260, the portion of the program that runs in Main works fine, but the procedure stops at y = 7, z = 260 - the program hangs, with ^C ineffective.
I'm running a pentium 400 under Win98. I've had no trouble with this in small arrays, but 256 seems to be a divide of some sort.
Any suggestions appreciated. Toby
Toby Ewing Soil Scientist, Iowa State University
Program TestLgArray;
Const Xmax = 25 ; {physical space - grid units} Ymax = 260; {physical space - grid units} Zmax = 260;
Type Compary = array[1..Ymax, 1..Zmax] of integer;
var Comp : Compary; x, y, z : integer;
{________________________________________________ } Procedure Zero;
var Comp : Compary; x, y, z : integer;
begin writeln('Procedure:'); readln; for y := 1 to Ymax do begin {zero the comp array} for z := 1 to Zmax do Comp[y,z] := 0; writeln('y=', y:3, ' z=', z:1); end; end; {________________________________________________ }
begin {Main Program} writeln('Main:'); readln; for y := 1 to Ymax do begin {zero the comp array} for z := 1 to Zmax do Comp[y,z] := 0; writeln('y=', y:3, ' z=', z:1); end; Zero; write(' done'); end.