Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!spool.mu.edu!uunet!gsm001!gsm From: gsm@mendelson.com (Geoffrey S. Mendelson) Newsgroups: comp.os.coherent Subject: Re: compiler bug Message-ID: <1991Apr26.031408.23686@mendelson.com> Date: 26 Apr 91 03:14:08 GMT References: <1991Apr25.183957.11195@Arco.COM> Organization: Mendelson Computer Consulting Lines: 71 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. | ---------------------------------------------------------------------------