Segmentation Fault 11 while using SOIL

Hi,

I’m currently trying to load a CubeMap Texture with SOIL. The program is compiling and linking correctly, but when starting it, the error log says Segmentation fault: 11 and the programm is closed immediately. I know from other issues, that this error means, that I’m accessing some memory I didn’t allocate before. But I can’t figure out where the problem is here.

My System: Mac OS X 10.9.2
Editor: Eclipse IDE for C/C++ Developers Kepler

After defining the box as an GLfloat array, I do:


tex = SOIL_load_OGL_cubemap (
    		"Skybox/stormy_right.jpg",
    		"Skybox/stormy_left.jpg",
    		"Skybox/stormy_top.jpg",
    		"Skybox/stormy_bottom.jpg",
    		"Skybox/stormy_back.jpg",
    		"Skybox/stormy_front.jpg",
    		SOIL_LOAD_RGB,
    		SOIL_CREATE_NEW_ID,
    		0
    );

    glBindTexture(GL_TEXTURE_CUBE_MAP, tex);

    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);

    if (0 == tex) {
      printf("SOIL loading error: '%s'
", SOIL_last_result());
    }

where tex is defined as GLuint in the Header file. Next step is generating and binding buffers, which should not be the problem.
Rendering is done like this:


glDisable(GL_DEPTH_TEST);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_CUBE_MAP, tex);

glBindVertexArray(vaoHandle);

glDrawArrays(GL_TRIANGLES, 0, 36);

I’m using vertex and fragment shaders just as usual.

Interesting ist the following:
when I do tex = 5 just for testing, the error disappears. Naturally there is no texture loaded then, but I think this show that the problem is the SOIL_load_OGL_cubemap() function.

I hope someone can find the mistake I’m making.