Path: utzoo!utgpu!water!watmath!clyde!rutgers!sdcsvax!ucbvax!unisoft!gethen!farren From: farren@gethen.UUCP (Michael J. Farren) Newsgroups: comp.lang.c Subject: Re: How to Trap Runtime System Error under MSC? Message-ID: <593@gethen.UUCP> Date: 16 Jan 88 06:17:58 GMT References: <11263@brl-adm.ARPA> Reply-To: farren@gethen.UUCP (Michael J. Farren) Organization: There's Unix there in Oakland Lines: 26 In article <11263@brl-adm.ARPA> MHARRIS@G.BBN.COM writes: >Can anyone tell me how to trap Microsoft C "serious runtime errors", e.g., >"Error 2000 Stack Overflow", before they print to the terminal screen? >I want to deal with them myself in the code that evoked the offending >.EXE file (with system()). Thanks. Without hacking the source code to the runtime package, you can't, for the most part. The 'Stack Overflow' messages are a special case, as they are produced by a routine called, I believe, _chkstk, and you could easily replace this routine with one of your own. The thing to keep in mind, though, is that the error detection embedded in the runtime package is designed to allow the code to gracefully recover from disastrous errors, under which there would be no guarantee that YOUR code would execute properly, if at all. Stack checking, for example, is invoked on entry to a function, and simply determines if there is enough room on the stack for allocation of all the auto variables. While you could write a replacement routine that 'grew' the stack, you would have to ensure that that routine did not use the existing stack, or you would be setting yourself up for a royal fall. Similar constraints apply for other runtime errors. -- Michael J. Farren | "INVESTIGATE your point of view, don't just {ucbvax, uunet, hoptoad}! | dogmatize it! Reflect on it and re-evaluate unisoft!gethen!farren | it. You may want to change your mind someday." gethen!farren@lll-winken.llnl.gov ----- Tom Reingold, from alt.flame