Microsoft KB Archive/78384

= Basic .EXE >230K Linked with EXEPACK (/EX) Option May Hang =

Article ID: 78384

Article Last Modified on 11/21/2006



This article was previously published under Q78384



SYMPTOMS
Executable programs (.EXE) that exceed approximately 230K-300K in size and that are linked with the /EXEPACK (or /EX) option may hang at run time. The problem does not occur when programs are linked without the /EXEPACK option.



STATUS
Microsoft has confirmed this to be a bug in Microsoft QuickBasic version 4.5 (buglist4.50) for MS-DOS and in Microsoft Basic Professional Development System (PDS) versions 7.0 and 7.1 (buglist7.00, buglist7.10) for MS-DOS. The problem occurs with all known versions of Microsoft LINK.EXE that support the /EXEPACK link option (LINK 3.51 and later 3.x versions, 4.x, 5.01.20, 5.01.21, 5.02, 5.03, 5.05, 5.10, 5.11, 5.13, and 5.15). We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.



MORE INFORMATION
The /EXEPACK switch causes large sequences of identical bytes in the .EXE file to be packed at link time and unpacked at run time. Normally, the LINK /EXEPACK option correctly packs the relocation table stored in the .EXE header. But /EXEPACK incorrectly packs the relocation table under the following circumstances:

When the number of relocatable items appearing in the .EXE header of a program linked without the /EXEPACK (or /EX) option exceeds about 16K, the program will hang at run time if re-linked with the /EXEPACK option. Because the number of relocatable items is roughly related to the size of an .EXE file, the hanging problem starts to occur when an .EXE file exceeds approximately 230K-300K in size.

Using a utility such as EXEHDR.EXE provided with Basic PDS version 7.0 or 7.1, you can determine the number of relocation items within an.EXE file that has not been linked with the /EXEPACK option. EXEHDR.EXE reports the information contained in the .EXE file's header. One of the items in the report is &quot;Relocations:&quot;. If the value corresponding to &quot;Relocations:&quot; exceeds about 4000 hex (or 16,384 decimal), the program will hang when re-linked with the /EXEPACK option.

Note: When you use EXEHDR.EXE to view the .EXE header of a program that has been linked with the /EXEPACK option, the number of &quot;Relocations:&quot; will always be zero. This is because the /EXEPACK option causes all relocation items to be packed.

To work around this problem, you must do one of the following:


 * Avoid using the LINK /EX option.

When you choose the Make Exe File option from the QB.EXE or QBX.EXE environment, the /EX option (EXEPACK) is automatically added to the link options. To link without the /EX option, you must compile with BC.EXE (outside the QB.EXE or QBX.EXE environment) and link the program from the DOS command line. -or-


 * Reduce the number of relocation items generated for a program.

Because the number of relocation items in the .EXE header of a program are directly related to the amount of code, the only way to reduce the number of relocation items is to reduce the amount of code. Code can be reduced by eliminating compiler options that add code to the program. For example, Debug, CodeView, and certain optimization options could be eliminated to reduce the amount of compiled code. Deleting or modifying code may also be required.

Example
This problem can be duplicated by using a Basic code generator to generate a program containing seven modules. Each module contains 2500 CLS (clear screen) statements for a total of 17500 CLS statements for the program. When only six of the seven modules are linked together, the problem does not occur. The program was compiled using QuickBasic version 4.5 and linked with LINK.EXE version 3.69. The problem also occurred when compiled with Basic PDS version 7.1 and linked with LINK.EXE version 5.1.

Additional query words: QuickBas BasicCom 4.50 7.00 7.10 buglist7.00 buglist7.10

Keywords: KB78384

-

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

© Microsoft Corporation. All rights reserved.