QCW9201003: QuickWin App UAEs If String Length Multiple of 512

ID Number: Q79822

1.00

WINDOWS

buglist1.00

Summary:

PROBLEM ID: QCW9201003

SYMPTOMS

Microsoft QuickC for Windows (QC/Win) version 1.0 contains QuickWin

libraries that provide the ability to convert an MS-DOS application

to a Windows application. However, if a printf statement contains a

"%s\n" and the string to be printed has a length that is a multiple

of 512 characters, including the null ('\0') terminator, an

unrecoverable application error (UAE) will occur when running the

program. If you run the program from QuickC for Windows, the

message "general protection violation (Trap 13)" will be generated.

RESOLUTION

The sample code below demonstrates the problem and lists

workarounds. To eliminate this problem, do one of the following:

1. Remove the "\n" from the format string, or move it to the next

printf statement.

2. Change the length of the string by 1 in either direction (the

maximum string length is 2048).

3. Add text or additional variables to the format string.

STATUS

Microsoft has confirmed this to be a problem in QuickC for Windows

version 1.0. We are researching this problem and will post new

information here as it becomes available.

More Information:

Sample Code

-----------

/* Compile options needed:

Options.Project menu - select "QuickWin EXE" */

#include <stdio.h>

#include <malloc.h>

#include <memory.h>

#define STRING_LENGTH 512

void main()

{

char * string;

string= (char *) malloc (STRING_LENGTH);

memset(string, 'a', STRING_LENGTH); /* Fill memory with 'a' */

string[STRING_LENGTH-1]= '\0';

printf("%s\n", string); /* causes trap */

/* possible fixes:

printf("%s", string); printf("\n"); separate \n from string

printf("Hello %s\n", string); text added to format string

printf("%s \n", string); text added to format string

change STRING_LENGTH by 1

*/

}

Additional reference words: qcwin qcw 1.00