Internal Error During ParseDefSections

Problem

When attempting to build a VxD, an ill-formed module definition file may induce some versions of Microsoft’s COFF linker to fail with the following error message:

LINK : error : Internal error during ParseDefSections 

Analysis

This internal error means that a CPU exception has occurred after entry to the ParseDefSections function but before the linker gets round to recording that it has progressed to some other function. (Strictly speaking, this ParseDefSections function is known by that name only for the purpose of reporting errors. Whether the function is called by that name in Microsoft’s source code is of no interest here.)

Cause

The invalid syntax known to induce this internal error is that an OBJECTS, SECTIONS or SEGMENTS statement in the module definition file has an incomplete section definition of the form:

section CLASS 

with only spaces, tabs, single quotes or comments to follow on the same line.

When building a VxD, the linker simply assumes that the CLASS keyword comes with a class name. Failure to supply text that can be interpreted as a class name induces the linker to attempt reading from a NULL pointer, hence the CPU exception that is reported as an internal error. (When building other executables, class names are allowed in section definitions but are ignored.)

Applicable Versions

Since this can “impact” only on VxD programmers, and only then when they make a mistake, it’s hardly surprising that the bug has lingered. It is present in the LINK.EXE version 2.60.5046 supplied with the Windows 95 DDK and in versions 3.00.5270, 3.10.6038, 4.20.6164 and 5.00.7022 from Microsoft Visual C++ 4.0, 4.1, 4.2 and 5.0 respectively.