dprrhb@inetg1.ARCO.COM (Reginald H. Beardsley) (04/26/91)
I installed a friend's copy of Coherent on a Compaq LTE/286 for a week or so last summer. (He didn't have disk space on his machine so we borrowed one from work) I think this was 3.0 as he said that he later got an update from MWC. In the process of noodling around with it I wrote the following program: #define SIZE ????? int main() { char buffer[SIZE]; int i; for( i=0; i<SIZE; i++ ){ buffer[i]=(char)i/256; } } The intent of the program was to test the protected mode operation and the limits on the array sizes. I varied the array size from small to 64k; Above 3-4K I got very peculiar behavior. The machine would do a hard reset (cntrl-alt-del) when I ran the program. No core dump, no file sync, just reset. I uninstalled Coherent and returned the machine. When Minix 1.5 came out from PH, I bought a copy and borrowed the machine again. Very happy with Minix. Now if I can just hang on to the machine..... Does anyone running Coherent have any thoughts on this? Was it the machine or the software? NB: If you try running the program make sure you sync before you execute it, saves a lot of trouble for fsck. If you e-mail to me I will summarize for the group. -- Reginald H. Beardsley ARCO Information Services Plano, TX 75075 Phone: (214)-754-6785 Internet: dprrhb@arco.com
gsm@mendelson.com (Geoffrey S. Mendelson) (04/26/91)
dprrhb@inetg1.ARCO.COM (Reginald H. Beardsley) > > I installed a friend's copy of Coherent on a Compaq LTE/286 for a week or so last summer. (He didn't have disk space on his machine so we borrowed one from >work) I think this was 3.0 as he said that he later got an update from MWC. >In the process of noodling around with it I wrote the following program: > ........................ > >Does anyone running Coherent have any thoughts on this? Was it the machine >or the software? NB: If you try running the program make sure you sync before >you execute it, saves a lot of trouble for fsck. If you e-mail to me I will >summarize for the group. >-- There is nothing wrong with the compiler, the problem you describe is "feature" of coherent. Memory allocated during execution is taken from the infamous stack. This includes variables inside subprograms. If you intend to use more than 2k in stack space, run fixstack (q.v.) to increase the stack. For example "fixstack 1000 module" will ADD 4k (1000 hex) to the stack of the module. The problem lies with the runtime modules being so ungraceful about stack overflows. To improve speed, there is no error checking on stack allocation. The stack overwrites program code, and oops, down goes coherent. There should be a compiler option to select stack checking. It would slow down programs by at least an order of magnitude. DO NOT TRY TO FIX THE STACK OF THE SHELL (sh). The stack the shell uses is a carefully managed (and checked) stack. fixstack will do nothing but make the shell bigger and slower. Examples of allocation: From program segement (no stack usage): int big_array[16384]; /* 32k array*/ main() { } From stack (will probably blow up): main() { int big_array[16384]; /* 32k array*/ } And of course: main() { int dummy; int *big_array[16484] /* allocates no space at all */ big_array = malloc(16384*sizeof(dummy)); /*Try and get it from the stack */ } -- Copyright (C) 1991, Geoffrey S. Mendelson. All Rights Reserved. Except for usenet followups, may not be reproduced without permsission. ---------------------------------------------------------------------------- | Geoffrey S. Mendelson | Computer Software Consulting | Dr. | | (215) 242-8712 | IBM Mainframes, Unix, PCs, Macs | Who | | gsm@mendelson.com | | Fan too!| ---------------------------------------------------------------------------- | WANTED: PAL VIDEO TAPES (VHS or BETA) inquire within. | | Especialy "missing" Dr Who Episodes. | ---------------------------------------------------------------------------
david@bacchus.esa.oz.au (David Burren [Athos]) (05/05/91)
I couldn't resist this: In <1991Apr26.031408.23686@mendelson.com> gsm@mendelson.com (Geoffrey S. Mendelson) writes: >main() >{ > int dummy; > int *big_array[16484] /* allocates no space at all */ BZZZT. It allocates space for an array of 16484 pointers to ints. Btw, didn't you mean 16384? A #define would avoid that problem. I think what you meant to use was something like: int *big_array; > big_array = malloc(16384*sizeof(dummy)); /*Try and get it from the stack */ >} _____________________________________________________________________________ David Burren [Athos] Email: david@bacchus.esa.oz.au Software Development Engineer Phone: +61 3 819 4554 Expert Solutions Australia, Hawthorn, VIC Fax: +61 3 819 5580