Microsoft KB Archive/922279

= BUG: Error message when you run a Visual C++ program that calls the execve function or the wexecve function in Visual Studio 2005: &quot;The application failed to initialize properly (0xc0150004)&quot; =

Article ID: 922279

Article Last Modified on 2/7/2007

-

APPLIES TO


 * Microsoft Visual Studio 2005 Professional Edition
 * Microsoft Visual Studio 2005 Standard Edition
 * Microsoft Visual Studio 2005 Team System Architect Edition
 * Microsoft Visual Studio 2005 Team System Developer Edition
 * Microsoft Visual Studio 2005 Team Foundation
 * Microsoft Visual Studio 2005 Team System Test Edition

-





SYMPTOMS
In Microsoft Visual Studio 2005, when you run a Microsoft Visual C++ program that calls the execve function or the wexecve function, you may receive the following error message:

The application failed to initialize properly (0xc0150004). Click on OK to terminate the application.



CAUSE
This issue occurs when the following conditions are true:
 * A Visual C++ parent program calls the execve function or the wexecve function to load and to execute a child process
 * The envp parameter of the execve function or the wexecve function contains an empty string.



RESOLUTION
To resolve this issue, make sure that the envp parameter of the execve function or the wexecve function does not contain an empty string.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the &quot;Applies to&quot; section.



MORE INFORMATION
The following steps reproduce the problem that is mentioned in the &quot;Symptoms&quot; section. Additionally, the steps demonstrate how to correct the problem by using the method that is described in the &quot;Resolution&quot; section.

Steps to reproduce the problem
 Create a parent Visual C++ project that is named T.cpp.  Add the following code example to T.cpp.
 * 1) include 
 * 2) include 
 * 3) include 
 * 4) include 

TCHAR * args1[] = { _T(&quot;child.exe&quot;), 0 };

TCHAR * envs2[] = { _T(&quot;&quot;), 0 };

int main { if ( _execve( &quot;child.exe&quot;, args1, envs2  ) == -1 ) {  printf(&quot;failed\n&quot;); return 1; }  Create a child Visual C++ project that is named Child.cpp.</li>  Add the following code example to Child.cpp.
 * 1) include <stdio.h>

int main { printf(&quot;hello\n&quot;); } </li> Compile and then run T.cpp and Child.cpp. You receive the error message that is mentioned in the &quot;Symptoms&quot; section.</li></ol>

To correct the problem that occurs after you reproduce the problem, follow these steps: <ol>  In T.cpp. paste the following value into the envs2[] parameter to replace the empty string: &quot;myenv=A&quot; T.cpp now resembles the following code example.
 * 1) include <stdio.h>
 * 2) include <process.h>
 * 3) include <tchar.h>
 * 4) include <stdlib.h>

TCHAR * args1[] = { _T(&quot;child.exe&quot;), 0 };

TCHAR * envs2[] = { _T(&quot;myenv=A&quot;), 0 };

int main { if ( _execve( &quot;child.exe&quot;, args1, envs2  ) == -1 ) {  printf(&quot;failed\n&quot;); return 1; } </li> Compile and then run T.cpp. The program works correctly.</li></ol>

Keywords: kbtshoot kberrmsg kbexpertiseinter kbbug KB922279

-

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

© Microsoft Corporation. All rights reserved.