Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Error message when you run an application that is configured to be built for the x64 platform by using the MSVCRT.dll file that calls the strncpy function: "An unhandled win32 exception occurred in 'application_name'".


View products that this article applies to.

Symptoms

You have an application that is configured to be built for an x64 platform by using the MSVCRT.dll file which was included in Windows Server 2003 SP1 SDK. The application calls the strncpy function. When you run the application, you may receive the following error message:

An unhandled win32 exception occured in 'application_name'

When you check the call stack, you may find an access violation was triggered in the MSVCRT.dll file and that the application stopped responding in the strncpy function. This problem occurs when the following conditions are true:
The source buffer extends to the end of an allocated page.
The next byte after this page does not belong to the running process.
The length to be copied is an even multiple of 8.
The length to be copied includes the final byte of the source buffer.

This access violation occurs with MSVCRT.DLL in system32 folder.

↑ Back to the top


Cause

This problem occurs because the strncpy function tries to access the next byte after the source buffer. This issue is introduced by new optimizations to some CRT library functions.

↑ Back to the top


Resolution

Work around
To work around this problem, use one of the following methods:
Change any of the four conditions that are described in the "Symptoms" section.
Replace the strncpy function with other functions that have the similar functionality, such as the memcpy function or the lstrcpyn function.

Note These copy functions are slightly different. For example, the memcpy function does not end the string copy when a null byte is encountered before the indicated length.

↑ Back to the top


More information

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

KB956420 mentions a bug in the strncpy function regarding to MSVCRT90.DLL.
The same problem exists in the MSVCRT.dll included in Platform SDK (Windows Server 2003 SP1 SDK) and the MSVCRT.dll included in the OS.

KB956420
FIX: Error message when you run an application that is configured to be built for the x64 platform by using the MSVCR90.dll file that calls the strncpy function: "An unhandled win32 exception occurred in 'application_name'"



↑ Back to the top


Note This is a "FAST PUBLISH" article created directly from within the Microsoft support organization. The information contained herein is provided as-is in response to emerging issues. As a result of the speed in making it available, the materials may include typographical errors and may be revised at any time without notice. See Terms of Use for other considerations.

↑ Back to the top


Keywords: KB2255016

↑ Back to the top

Article Info
Article ID : 2255016
Revision : 1
Created on : 7/15/2010
Published on : 7/15/2010
Exists online : False
Views : 353