Null Pointer Assignment

draper at inmet.inmet.com draper at inmet.inmet.com
Wed Oct 17 02:47:00 AEST 1990


/* Written  9:53 am  Oct 13, 1990 by darcy at druid.uucp in inmet:comp.lang.c */
In <27154927-274.1comp.lang.c-1 at tronsbox.xei.com> Bill Cavanaugh writes:
>>>not come up until the end of the program.  In fact, I put in the line
>>>
>>>printf("done\n");
>>>exit(0);
>>>
>>>at the end of my main, and when executed, it says
>>>
>>>done
>>>Null Pointer Assignment
>>>
>>>Does this make sense?  Thanks for any suggestions.
>>>
>>I'm not sure about the message, so I won't comment on that, but the reason
>>the message is coming up after the printf() is that the printf() sends it's
>>output to stdout, and the message is going to stderr....
>>
>Wrong.  The Null Pointer Assignment message is generated *AFTER* main returns.
>The C startup code looks at the copyright message at address 0 to see if it
>was modified anytime during the run.  This is necessary on DOS systems as
>there is no memory protection to generate an exception.  This check at the
>end of the program is designed to give some indication that a NULL pointer
>was dereferenced.  The error however could have happened anywhere in the
>program.  To find it you have to use your debugger to follow the values
>at DS:0 or set a watch up for that memory location.  Check your debugger
>documentation for details.
/* End of text from inmet:comp.lang.c */


When I first started programming in C using MSC 4.0 I ran into this
message on several occasions. I traced it down to some sloppy code
and coding techniques used to parse command line arguments.

If you are using argc,argv in your code that is where I
would start looking.


- Dave Draper

It's not a bug ... it's a feature.


Internet: draper at inmet.inmet.com
UUNET: uunet!inmet!draper
-----
Intermetrics Microsystems Software, Incorporated
733 Concord Avenue	   Cambridge,  MA  02138
(617) 661-0072 x4573



More information about the Comp.lang.c mailing list