QNX RTOS v4 Knowledge Base
QNX RTOS v4 Knowledge Base
Title |
"NULL assignment detected" message |
Ref. No. |
QNX.000009323 |
Category(ies) |
Development |
Issue |
My application runs flawlessly, but as soon as it exits I get a "NULL assignment detected" message. What does this mean and how can I get rid of it?
|
Solution |
If you're getting this message, your application only seems to be running flawlessly. In fact, it's making an assignment to an uninitialized (or incorrectly initialized) pointer, a condition that will eventually cause problems if left unfixed.
You're getting this message because Watcom has placed a handy debug tool right into the runtime library. This tool places 32 bytes of 0x01 at the base of the data segment. When your program has finished running, the exit code checks that the data segment still contains this value. If it doesn't, you get the "NULL assignment detected" message. x09To pinpoint the problem, follow these steps:
x091.x09Make sure you've compiled the program with the -g 2 option to produce debug information in the executable. For example:
x09x09cc sample.c -o sample -g 2
x092.x09Run the WATCOM debugger on the program:
x09x09wvideo sample
x093.x09Using the debugger's command-line (DBG>), set a watchpoint on the null area:
x09x09watch _nullarea
x094.x09Enter go on the command line to execute the program.
x09When the program makes the NULL assignment, the debugger will stop and show you which line caused the write. Bingo, you've found your NULL pointer assignment!
|
|