Null Pointer Assignment

D'Arcy J.M. Cain darcy at druid.uucp
Sat Oct 13 23:53:03 AEST 1990


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.

-- 
D'Arcy J.M. Cain (darcy at druid)     |
D'Arcy Cain Consulting             |   I support gun control.
West Hill, Ontario, Canada         |   Let's start with the government!
+ 416 281 6094                     |



More information about the Comp.lang.c mailing list