title: segfault on glBufferData
body: <p>I'm trying to port my fixed function pipeline openGL code to use GLSL, but I'm having a segfault happen with <code>glBufferData</code>.  This was all working very well with the fixed-function stuff (i.e. I could render the loaded mesh no problem).</p>
  
  <p>Here's the code that loads the vertices (from the AssImp importer library):</p>
  
  <p>Defined in the Mesh.h file:</p>
  
  <pre><code>...
  glm::detail::uint32 vaoId_[];
      glm::detail::uint32 vboIds_[];
  
      std::vector&lt; glm::vec3 &gt; vertices_;
      std::vector&lt; glm::vec3 &gt; normals_;
      std::vector&lt; glm::vec2 &gt; textureCoordinates_;
      std::vector&lt; glm::vec4 &gt; colors_;
  ...
  </code></pre>
  
  <p>implemented in Mesh.cpp:</p>
  
  <pre><code>...
  Mesh::Mesh(const aiMesh* mesh) {
      vaoId_[1];
      vboIds_[4];
  
      BOOST_LOG_TRIVIAL(debug) &lt;&lt; "loading mesh...";
  
      glm::detail::uint32 currentIndex = 0;
  
      for (glm::detail::uint32 t = 0; t &lt; mesh-&gt;mNumFaces; ++t) {
          const aiFace* face = &amp;mesh-&gt;mFaces[t];
          GLenum face_mode;
  
          switch(face-&gt;mNumIndices) {
              case 1: face_mode = GL_POINTS; break;
              case 2: face_mode = GL_LINES; break;
              case 3: face_mode = GL_TRIANGLES; break;
              default: face_mode = GL_POLYGON; break;
          }
  
          glm::detail::uint32 numIndices = face-&gt;mNumIndices;
  
          vertices_.resize( currentIndex + numIndices );
          normals_.resize( currentIndex + numIndices );
          textureCoordinates_.resize( currentIndex + numIndices );
          colors_.resize( currentIndex + numIndices );
  
          //BOOST_LOG_TRIVIAL(debug) &lt;&lt; "loading face: " &lt;&lt; face-&gt;mNumIndices;
          // go through all vertices in face
          for(glm::detail::uint32 i = 0; i &lt; numIndices; i++) {
              // get group index for current index i
              int vertexIndex = face-&gt;mIndices[i];
  
              if (mesh-&gt;mNormals != 0) {
                  vertices_[currentIndex + i]     = glm::vec3( mesh-&gt;mVertices[vertexIndex].x, mesh-&gt;mVertices[vertexIndex].y, mesh-&gt;mVertices[vertexIndex].z );
                  normals_[currentIndex + i]      = glm::vec3( mesh-&gt;mNormals[vertexIndex].x, mesh-&gt;mNormals[vertexIndex].y, mesh-&gt;mNormals[vertexIndex].z );
              }
  
              if (mesh-&gt;HasTextureCoords(0)) {
                  textureCoordinates_[currentIndex + i] = glm::vec2( mesh-&gt;mTextureCoords[0][vertexIndex].x, mesh-&gt;mTextureCoords[0][vertexIndex].y );
              }
  
              //utilities::AssImpUtilities::color4_to_vec4(&amp;mesh-&gt;mColors[0][vertexIndex], colors_[colors_.size() + i]);
              if (mesh-&gt;mColors[0] != 0) {
                  colors_[currentIndex + i]           = glm::vec4(
                                                          (float)mesh-&gt;mColors[0][vertexIndex].a,
                                                          (float)mesh-&gt;mColors[0][vertexIndex].b,
                                                          (float)mesh-&gt;mColors[0][vertexIndex].g,
                                                          (float)mesh-&gt;mColors[0][vertexIndex].r
                                                      );
              }           
          }
  
          currentIndex += 3;
      }
  
      BOOST_LOG_TRIVIAL(debug) &lt;&lt; "loading mesh into video memory...";
  
      BOOST_LOG_TRIVIAL(debug) &lt;&lt; "blah: " &lt;&lt; vertices_.size();
      BOOST_LOG_TRIVIAL(debug) &lt;&lt; "blah: " &lt;&lt; ( sizeof(glm::vec3) );
      BOOST_LOG_TRIVIAL(debug) &lt;&lt; "blah: " &lt;&lt; ( &amp;vertices_[0] );
  
      // create our vao
      glGenVertexArrays(1, &amp;vaoId_[0]);
      glBindVertexArray(vaoId_[0]);
  
      // create our vbos
      //glGenBuffers(4, &amp;vboIds_[0]);
      glGenBuffers(1, &amp;vboIds_[0]); // Using only '1' for now (otherwise causes seg fault)
      glBindBuffer(GL_ARRAY_BUFFER, vboIds_[0]);
      glBufferData(GL_ARRAY_BUFFER, vertices_.size() * sizeof(glm::vec3), &amp;vertices_[0], GL_STATIC_DRAW);
  
      glEnableVertexAttribArray(0);
      glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
  
      // Disable our Vertex Buffer Object
      glBindVertexArray(0);
  
      BOOST_LOG_TRIVIAL(debug) &lt;&lt; "done loading mesh...";
  }
  ...
  </code></pre>
  
  <p>I can't seem to figure out why opengl gives a segfault when I call <code>glBufferData(GL_ARRAY_BUFFER, vertices_.size() * sizeof(glm::vec3), &amp;vertices_[0], GL_STATIC_DRAW);</code>.</p>
  
  <p>full error is (using gdb in linux):</p>
  
  <blockquote>
    <p>Program received signal SIGSEGV, Segmentation fault.
    0x00007fffefb1ae70 in ?? () from
    /usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.304.64</p>
  </blockquote>
  
  <p>Anyone have any ideas?  </p>