Microsoft KB Archive/71252

= Null Pointer Assignment =

Article ID: 71252

Article Last Modified on 10/23/2003

-

APPLIES TO


 * Microsoft CodeView 4.1
 * Microsoft CodeView 3.0
 * Microsoft CodeView 3.0
 * Microsoft CodeView 3.0
 * Microsoft CodeView 4.0
 * Microsoft CodeView 4.01
 * Microsoft CodeView 4.01
 * Microsoft CodeView 4.1
 * Microsoft CodeView 3.0
 * Microsoft CodeView 3.0
 * Microsoft CodeView 4.1
 * Microsoft CodeView 4.1
 * Microsoft CodeView 4.1

-



This article was previously published under Q71252





SYMPTOMS


RESOLUTION


STATUS


MORE INFORMATION
The location of the null segment can be observed in a link map. It starts at DS:0 and is 42H bytes long. The Microsoft copyright notice is written there at program startup and if this area is written to during the course of the program, the run-time error R6001 will be generated upon program termination.

The most common cause of this error is using a pointer that has not been initialized to point to a memory area. Pointers that have not had space allocated for them [for example, with malloc] or that have not been assigned to point to a specific data element (for example, arrays or structures) are considered uninitialized. Writing to one of these pointers generally results in an overwrite of the null data segment.

With CodeView versions 1.0, 2.0, 2.1, 2.2, 2.3, and 2.35, the procedure described above should be used for locating the source of an R6001 error. With CodeView versions 3.0 and above, you may also use the following menu and keyboard commands to set the breakpoint for tracking down a null pointer assignment:
 * 1) Press the F8 or F10 key to step into main.
 * 2) Select Set Breakpoint from the Watch menu.
 * 3) Choose &quot;Break When Expression Has Changed&quot; from the Set Breakpoint dialog box.
 * 4) In the Expression field, enter DS:0.
 * 5) In the Length field, enter 0n66.
 * 6) Choose OK, or press ENTER.
 * 7) Press the F5 key to run the program.

As described above, the program will then break immediately after the errant pointer has written to the null segment.

Note that it may be necessary to clear any breakpoints on the null data segment and restart the program before entering the above commands in order for these procedures to work correctly.

In addition, any breakpoint on DS:0 may stop execution if DS changes. For example, if the above breakpoint is set and the program is restarted under CodeView, the program will break during the C start-up code [before reaching the main function], since the C start-up sets DS to the default data segment. [This is also the reason you must step into main before setting the breakpoint in the first place, otherwise you would not be setting the breakpoint on the correct segment.

Additional query words: kbinf 3.00 4.00 4.10

Keywords: kb16bitonly kbprb KB71252

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.