Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!rutgers!ucla-cs!sdcrdcf!burdvax!bpa!cbmvax!vu-vlsi!colin
From: colin@vu-vlsi.UUCP (Colin Kelley)
Newsgroups: comp.sys.ibm.pc
Subject: MSC signal() and free() problems
Message-ID: <558@vu-vlsi.UUCP>
Date: Sat, 10-Jan-87 02:34:08 EST
Article-I.D.: vu-vlsi.558
Posted: Sat Jan 10 02:34:08 1987
Date-Received: Sun, 11-Jan-87 09:35:48 EST
Organization: Villanova Univ. EE Dept.
Lines: 31

I'm having trouble with a ^C handler using MSC 4.0 and PC-DOS 3.1.  I have
signal(SIGINT, interrupt); to call my routine interrupt() when ^C is pressed.
This works as expected, but sometimes bombs out with a stack overflow.
After further inspection with CodeView, it appears that SS register is always
left pointing at the DOS stack after a ^C rather than being restored to point
at the program's stack segment; since _chkstk() only looks at SP (not SS),
the stack check will sometimes succeed and sometimes fail.  However, the
program seems destined to fail if it continues to use the DOS stack rather
than its own!

One cheap work-around is to compile with the /Gs option to inhibit stack
overflow checks, but that's obviously not acceptable--it's just treating the
symptom, not the disease.

I recall reading somewhere on the net that the authors of Procomm experienced
the same or a similar problem, but I didn't see a solution posted...

Oh yeah, and while I'm at it, I think I've found a certain lack of
functionality in MSC's implementation of malloc() and free().  When testing my
program with CodeView, I only have about 32K of heap free.  The program
malloc()'s as many fixed-size chunks as it can, which turns out to be only 5
chunks.  This correctly uses up all 32K.  But then, if I free() all that
memory and try to malloc() it again, using the same size chunks, MSC only
succeeds in allocating 2 or 3 chunks before it reports that all memory has
been used.  This indicates that MSC's free() isn't doing a good job of merging
free()'d memory.  I experience the same trouble whether the chunks are
free()'d in the order they were malloc()'d or in the opposite order. 

Anyone got any suggestions/solutions for either problem?  Thanks!

	-Colin Kelley  ..{cbmvax,pyrnj,psuvax1,bpa}!vu-vlsi!colin