Turbo C program inconsistent runtime problems

Chad Price price at vlsiws.unl.edu
Sat Aug 25 07:15:00 AEST 1990


In <19962 at orstcs.CS.ORST.EDU> duvalj at bionette.cgrb.orst.edu (Joe Duval - Entomology) writes:

>The last thing I did was to add some function prototypes and move some 
>functions around to better organize the program.  This did involve splitting
>up one file into two.  The program was behaving OK before these changes, but
>not perfectly and is certainly worse than before. <:-)

>I would like to get some suggestions on where to start looking for the
>problems.  I haven't been able to pinpoint it to a specific point in the

>There are probably some pointers out there that don't get malloc'd correctly
>or start pointing to other things maybe.  This is a fairly large program and
>I would like to jump into debugging it with some direction.

>From your description, there are a lot of places to look, but it would
seem likely that you are experienceing either stack corruption or are
writing over video or other memory (probably including DOS's memory space)

As a place to start, I would compile the source with ALL of the Turbo
warnings turned on, and fix ALL of the warnings: remove all unused
variables, ensure that all pointers are properly initialized, check the
return values on all library and system calls that provide them. Then, if
you still have problems, start with the debugger, stepping through the
program 1 line at a time, checking relevant variable values and memory
locations as you go.

I had a similar problem some time ago with code I was porting from
FORTRAN to C and was eventually able to make the problem go away, but I
don't remember what eventually fixed it. IMO, the best approach is a
systematic approach: tackle one problem at a time and fix it before going
on. 

Good luck, as the process may be long.

Chad Price
price at fergvax.unl.edu



More information about the Comp.lang.c mailing list