Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!mit-eddie!interlan!backman From: backman@interlan.UUCP (Larry Backman) Newsgroups: comp.sys.ibm.pc Subject: Re: MSC signal() and free() problems Message-ID: <117@interlan.UUCP> Date: Mon, 12-Jan-87 13:32:41 EST Article-I.D.: interlan.117 Posted: Mon Jan 12 13:32:41 1987 Date-Received: Mon, 12-Jan-87 22:58:50 EST References: <558@vu-vlsi.UUCP> Reply-To: backman@interlan.UUCP (1014-Larry Backman) Organization: MICOM-Interlan, Boxborough, MA Lines: 36 In article <558@vu-vlsi.UUCP> colin@vu-vlsi.UUCP (Colin Kelley) writes: >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! > The reason you are getting DOS's stack is that you are trapping an interrupt! When ^C is hit, the SIGINT function will call your routine as an interrupt handler . It is your responsibility as an interrupt routine to set up your environment correctly. I had the same problem writing a series of NETBIOS POST routines; I solved it by a thin assembly interface that restored SS:SP back into my environment, and then calling C code. I eventually ended up turning off stack checking in a single module that handled NETBIOS because it was getting in my way as well as slowing down my code. I did however leave stack checking on in the other modules that were part of the program. I am curious about your problems with free and malloc. I am using them very heavily and have not seen problems with them. Could you provide a code fragment? Larry Backman Micom - Interlan, Inc. 155 Swanson Rd. Boxborough, Ma. 01719 617-263-9929 x291 ulowell! mit-eddie! interlan!backman ihnp4!