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

Article translations Article translations
Article ID: 922279 - View products that this article applies to.
Expand all | Collapse all

On This Page

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 "Applies to" section.

MORE INFORMATION

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

Steps to reproduce the problem

  1. Create a parent Visual C++ project that is named T.cpp.
  2. Add the following code example to T.cpp.
    #include <stdio.h>
    #include <process.h>
    #include <tchar.h>
    #include <stdlib.h>
    
    TCHAR * args1[] =
    {
     _T("child.exe"),
     0
    };
    
    TCHAR * envs2[] = 
    {
     _T(""),
     0
    };
    
    int main() {
     if ( _execve( "child.exe", args1, envs2   ) == -1 )
      {
       printf("failed\n");
       return 1;
      }
  3. Create a child Visual C++ project that is named Child.cpp.
  4. Add the following code example to Child.cpp.
    #include <stdio.h>
    
    int main() {
     printf("hello\n");
    }
    
    
  5. Compile and then run T.cpp and Child.cpp. You receive the error message that is mentioned in the "Symptoms" section.
To correct the problem that occurs after you reproduce the problem, follow these steps:
  1. In T.cpp. paste the following value into the envs2[] parameter to replace the empty string:
    "myenv=A"
    T.cpp now resembles the following code example.
    #include <stdio.h>
    #include <process.h>
    #include <tchar.h>
    #include <stdlib.h>
    
    TCHAR * args1[] =
    {
     _T("child.exe"),
     0
    };
    
    TCHAR * envs2[] = 
    {
     _T("myenv=A"),
     0
    };
    
    int main() {
     if ( _execve( "child.exe", args1, envs2   ) == -1 )
      {
       printf("failed\n");
       return 1;
      }
  2. Compile and then run T.cpp. The program works correctly.

Properties

Article ID: 922279 - Last Review: February 7, 2007 - Revision: 1.1
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
Keywords: 
kbtshoot kberrmsg kbexpertiseinter kbbug KB922279

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com