duvalj@bionette.cgrb.orst.edu (Joe Duval - Entomology) (08/23/90)
Hi, I am using TC 2.0, DOS 3.3, 386 machine. I have a Turbo C program that compiles fine with minimal warnings about variables not used (actually they are used inside of ifdefs). However, when it runs the program will crash, usually corrupting the screen horribly. This doesn't happen at the same point in the program all the time and sometimes will not happen until you run the program two or three times. The least that happens during a run is that you may get a "Null pointer assignment" message when the program exits to DOS. I did not write all of the code and the program has performed better in the past. I am using "Steven's Memory resident utilities/ Screen I/O & Programming" for windows and menus. I added the user interface. 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 program because it is inconsistent. 80% of the time the program just gets lots of colorful, flashing, random characters on the screen and will lock up the machine, but not at any one spot. Where should I start? What should I look for? Are there programs out there that will help me? I have tried the integrated debugger that comes with C but as soon as the program crashes I get some "system not ready error" and the machine needs to be rebooted. 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. Thanks for reading Send Help -Joe -- Joe Duval duvalj@bionette.cgrb.orst.edu Looking for 62-64 Chevy Nova body parts. I've got a 63 Nova SS forsale.
price@vlsiws.unl.edu (Chad Price) (08/25/90)
In <19962@orstcs.CS.ORST.EDU> duvalj@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@fergvax.unl.edu