TC 2.0 oddity - me or it ?

Bob Rusbasan rusbara2 at sage.cc.purdue.edu
Tue Nov 13 11:03:43 AEST 1990


In article <7131 at castle.ed.ac.uk> djm at castle.ed.ac.uk (D Murphy) writes:
>produces a Null pointer assignment message after it has finished. This
>is being caused by something after the last instruction (I tested this
>by adding puts("Last"); just before the closing brace of main() and got
>
>Last
>Null pointer assignment

I know this isn't an MS-DOS group, but could this possibly be put in
the faq posting if it isn't already?  Yes, it doesn't fit in with the
purpose of the group, but then it will stop (hopefully) this recurring
post that doesn't fit in with the purpose of the group...

To answer the question, TC (and MSC) have memory that they use in every
executable file (it contains error messages, the programs copyright,
and things like that).  This memory is at the beginning of the module.
If you write to address ds:0, which is what will happen if you write to
a null pointer, this are of the program gets trashed.

When the program is done running, it checks the integrity of this area.
If it has been written to, it gives you the NULL pointer message.  As
someone said, better late than never...

(One thing I find funny is that the NULL pointer error message is in
this memory area, so it often comes out looking rather funny!)

This doesn't really help you find the problem, but at least you know
there is one.  Just look through your code, run the debugger, or
whatever till you find where you're writing to a NULL pointer.  You
might want to start by wrapping all your mallocs, farmallocs, etc.,
in if statements to check the result of the allocation, assuming
you haven't done that already.

----------------------------------------------------------------------
| Bob Rusbasan          |  This space unintentionally left blank.    |
| bob at en.ecn.purdue.edu |                                            |
----------------------------------------------------------------------



More information about the Comp.lang.c mailing list