title: Unhandled exception at 0x00000000 in Engine.exe: 0xC0000005: Access violation
body: <p>I try to build this Tutorial: <a href="http://www.opengl-tutorial.org/beginners-tutorials/tutorial-2-the-first-triangle/" rel="nofollow">this one</a></p>
  
  <p>with the following code in window.cpp:</p>
  
  <pre><code>// Include standard headers
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  // Include GLEW
  #include &lt;GL/glew.h&gt;
  
  // Include GLFW
  #include &lt;GL/glfw.h&gt;
  
  //Include GLM
  #include &lt;glm/glm.hpp&gt;
  using namespace glm;
  
  #include &lt;common/shader.hpp&gt;
  
  int main( void )
  {
  // Initialise GLFW
  if( !glfwInit() )
  {
      fprintf( stderr, "Failed to initialize GLFW\n" );
      return -1;
  }
  
  glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4);
  glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
  glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
  glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
  
  // Open a window and create its OpenGL context
  if( !glfwOpenWindow( 1024, 768, 0,0,0,0, 32,0, GLFW_WINDOW ) )
  {
      fprintf( stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n" );
      glfwTerminate();
      return -1;
  }
  
  // Initialize GLEW
  if (glewInit() != GLEW_OK) {
      fprintf(stderr, "Failed to initialize GLEW\n");
      return -1;
  }
  
  glfwSetWindowTitle( "Tutorial 02" );
  
  // Ensure we can capture the escape key being pressed below
  glfwEnable( GLFW_STICKY_KEYS );
  
  // Dark blue background
  glClearColor(0.0f, 0.0f, 0.3f, 0.0f);
  
  GLuint VertexArrayID;
  glGenVertexArrays(1, &amp;VertexArrayID);
  glBindVertexArray(VertexArrayID);
  
  // Create and compile our GLSL program from the shaders
  GLuint programID = LoadShaders( "SimpleVertexShader.vertexshader", "SimpleFragmentShader.fragmentshader" );
  
  
  static const GLfloat g_vertex_buffer_data[] = { 
      -1.0f, -1.0f, 0.0f,
       1.0f, -1.0f, 0.0f,
       0.0f,  1.0f, 0.0f,
  };
  
  GLuint vertexbuffer;
  glGenBuffers(1, &amp;vertexbuffer);
  glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
  glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertex_buffer_data), g_vertex_buffer_data, GL_STATIC_DRAW);
  
  do{
  
      // Clear the screen
      glClear( GL_COLOR_BUFFER_BIT );
  
      // Use our shader
      glUseProgram(programID);
  
      // 1rst attribute buffer : vertices
      glEnableVertexAttribArray(0);
      glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
      glVertexAttribPointer(
          0,                  // attribute 0. No particular reason for 0, but must match the layout in the shader.
          3,                  // size
          GL_FLOAT,           // type
          GL_FALSE,           // normalized?
          0,                  // stride
          (void*)0            // array buffer offset
      );
  
      // Draw the triangle !
      glDrawArrays(GL_TRIANGLES, 0, 3); // From index 0 to 3 -&gt; 1 triangle
  
      glDisableVertexAttribArray(0);
  
      // Swap buffers
      glfwSwapBuffers();
  
  } // Check if the ESC key was pressed or the window was closed
  while( glfwGetKey( GLFW_KEY_ESC ) != GLFW_PRESS &amp;&amp;
         glfwGetWindowParam( GLFW_OPENED ) );
  
  // Close OpenGL window and terminate GLFW
  glfwTerminate();
  
  // Cleanup VBO
  glDeleteBuffers(1, &amp;vertexbuffer);
  glDeleteVertexArrays(1, &amp;VertexArrayID);
  
  return 0;
  }
  </code></pre>
  
  <p>`</p>
  
  <p>And the following code in the shader.cpp</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;algorithm&gt;
  using namespace std;
  
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  #include &lt;GL/glew.h&gt;
  
  #include "shader.hpp"
  
  GLuint LoadShaders(const char * vertex_file_path,const char * fragment_file_path){
  
  // Create the shaders
  GLuint VertexShaderID = glCreateShader(GL_VERTEX_SHADER);
  GLuint FragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER);
  
  // Read the Vertex Shader code from the file
  std::string VertexShaderCode;
  std::ifstream VertexShaderStream(vertex_file_path, std::ios::in);
  if(VertexShaderStream.is_open()){
      std::string Line = "";
      while(getline(VertexShaderStream, Line))
          VertexShaderCode += "\n" + Line;
      VertexShaderStream.close();
  }
  
  // Read the Fragment Shader code from the file
  std::string FragmentShaderCode;
  std::ifstream FragmentShaderStream(fragment_file_path, std::ios::in);
  if(FragmentShaderStream.is_open()){
      std::string Line = "";
      while(getline(FragmentShaderStream, Line))
          FragmentShaderCode += "\n" + Line;
      FragmentShaderStream.close();
  }
  
  
  
  GLint Result = GL_FALSE;
  int InfoLogLength;
  
  
  
  // Compile Vertex Shader
  printf("Compiling shader : %s\n", vertex_file_path);
  char const * VertexSourcePointer = VertexShaderCode.c_str();
  glShaderSource(VertexShaderID, 1, &amp;VertexSourcePointer , NULL);
  glCompileShader(VertexShaderID);
  
  // Check Vertex Shader
  glGetShaderiv(VertexShaderID, GL_COMPILE_STATUS, &amp;Result);
  glGetShaderiv(VertexShaderID, GL_INFO_LOG_LENGTH, &amp;InfoLogLength);
  std::vector&lt;char&gt; VertexShaderErrorMessage(InfoLogLength);
  glGetShaderInfoLog(VertexShaderID, InfoLogLength, NULL,
  &amp;VertexShaderErrorMessage[0]);
  fprintf(stdout, "%s\n", &amp;VertexShaderErrorMessage[0]);
  
  
  
  
  // Compile Fragment Shader
  printf("Compiling shader : %s\n", fragment_file_path);
  char const * FragmentSourcePointer = FragmentShaderCode.c_str();
  glShaderSource(FragmentShaderID, 1, &amp;FragmentSourcePointer , NULL);
  glCompileShader(FragmentShaderID);
  
  // Check Fragment Shader
  glGetShaderiv(FragmentShaderID, GL_COMPILE_STATUS, &amp;Result);
  glGetShaderiv(FragmentShaderID, GL_INFO_LOG_LENGTH, &amp;InfoLogLength);
  std::vector&lt;char&gt; FragmentShaderErrorMessage(InfoLogLength);
  glGetShaderInfoLog(FragmentShaderID, InfoLogLength, NULL,
  &amp;FragmentShaderErrorMessage[0]);
  fprintf(stdout, "%s\n", &amp;FragmentShaderErrorMessage[0]);
  
  
  
  
  // Link the program
  fprintf(stdout, "Linking program\n");
  GLuint ProgramID = glCreateProgram();
  glAttachShader(ProgramID, VertexShaderID);
  glAttachShader(ProgramID, FragmentShaderID);
  glLinkProgram(ProgramID);
  
  // Check the program
  glGetProgramiv(ProgramID, GL_LINK_STATUS, &amp;Result);
  glGetProgramiv(ProgramID, GL_INFO_LOG_LENGTH, &amp;InfoLogLength);
  std::vector&lt;char&gt; ProgramErrorMessage( max(InfoLogLength, int(1)) );
  glGetProgramInfoLog(ProgramID, InfoLogLength, NULL, &amp;ProgramErrorMessage[0]);
  fprintf(stdout, "%s\n", &amp;ProgramErrorMessage[0]);
  
  
  glDeleteShader(VertexShaderID);
  glDeleteShader(FragmentShaderID);
  
  return ProgramID;
  }
  </code></pre>
  
  <p>But when is run the code in debug mode ( i copied the full code from the Tutorial Files) my programm starts, but than it opens a errorwindow of Microsoft Visual C++ 2010 Express, the window contains the following error:</p>
  
  <pre><code>Unhandled exception at 0x00000000 in Engine.exe: 0xC0000005: Access violation.
  </code></pre>
  
  <p>My Debug Console show the following errors/outputs:</p>
  
  <pre><code>'Engine.exe': Loaded 'C:\Users\Domenik\Documents\Visual Studio 2010\Projects\Engine\Debug\Engine.exe', Symbols loaded.
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Program Files\AVAST Software\Avast\snxhk.dll', Cannot find or open the PDB file
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\opengl32.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\glu32.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\ddraw.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\dciman32.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\setupapi.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\devobj.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Users\Domenik\Documents\Visual Studio 2010\Projects\Engine\Debug\glew32.dll', Binary was not built with debug information.
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Symbols loaded.
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\winmm.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\nvoglv32.dll', Cannot find or open the PDB file
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\shell32.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\shlwapi.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\version.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\ntmarta.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\Wldap32.dll', Symbols loaded (source information stripped).
  'Engine.exe': Loaded 'C:\Windows\SysWOW64\powrprof.dll', Symbols loaded (source information stripped).
  The thread 'Win32 Thread' (0xcfc) has exited with code 0 (0x0).
  'Engine.exe': Unloaded 'C:\Windows\SysWOW64\powrprof.dll'
  The thread 'Win32 Thread' (0x1198) has exited with code 0 (0x0).
  The thread 'Win32 Thread' (0x538) has exited with code 0 (0x0).
  First-chance exception at 0x00000000 in Engine.exe: 0xC0000005: Access violation.
  Unhandled exception at 0x00000000 in Engine.exe: 0xC0000005: Access violation.
  The thread 'Win32 Thread' (0xdb0) has exited with code -805306369 (0xcfffffff).
  The thread 'Win32 Thread' (0x1370) has exited with code -805306369 (0xcfffffff).
  The program '[2624] Engine.exe: Native' has exited with code -805306369 (0xcfffffff).
  </code></pre>
  
  <p>my stack contains this:</p>
  
  <pre><code>00000000()  
  Engine.exe!main()  Line 54 + 0x12 bytes C++
  Engine.exe!__tmainCRTStartup()  Line 555 + 0x19 bytes   C
  Engine.exe!mainCRTStartup()  Line 371   C
  kernel32.dll!@BaseThreadInitThunk@12()  + 0x12 bytes    
  ntdll.dll!___RtlUserThreadStart@8()  + 0x27 bytes   
  ntdll.dll!__RtlUserThreadStart@8()  + 0x1b bytes    
  </code></pre>
  
  <p>I had read that the pointer NULL (it find it´s use 4 times in the shader.cpp) can crash the programm if it is to often in use. That sounds so, that i can change them all to 0 or 0L but this don´t fix it.</p>