Bart,

> you are (in your words) 110% right.

> At the time I had fixed the stack offenders but got lost in debugging
> adapting your stack-checking patch to other compilers (it actually
> checks the heap too, if heap grows to stack).

heap growing to stack *without stack check enabled) is a REAL BAD IDEA. (not 
your idea, I know)

let me explain.

ignoring recursion for the moment, maximum stack use
   can be statically evaluated
   will not change unless you make major changes
   you can request the required amount using some linker switch, and
   rely that this amount will always be available; no stack checking
   in production code necessary.

also: requesting stack (like calling a function) *must not fail*,
otherwise CRASH.


in contrast, malloc() may fail; virtually all malloc ocde runs like

  char *p = malloc(some_amount);
  if (p == NULL)
     {                   // fail decently,  dont CRASH
     printf("unable to allocate");
     return FALSE;
     }

now consider a heap that grows into the stack:

depending on the programs allocating history there may be
sometimes enough stack, sometimes not.
sometimes you see funny characters in your editor, sometimes the
linked list pointer gets overwritten.

 this is just asking for
trouble, and extremely frustrating debugging sessions.

Tom






_______________________________________________
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to