glLinkProgram fails but works on another machine

I was working on a text rendering program in C when suddenly one of my shaders started failing when one of my shaders started failing at the glLinkProgram step. This was strange to me as I had not touched that part of the code in a while and the code ran with no problems on another machine. I messed around with my shaders and it seemed to fail when one of my uniform floats like “total_time” was called used in a sin() or abs() call. This shader was a quick one I wrote to make the glyphs wiggle and change color so it is a little weird, but I don’t see any problems with it. Could this be a driver error or am I missing something more obvious? It mentions stack overflow in the error message, but I don’t understand what would cause this. I have an Intel graphics card.

Error message:

Unhandled exception at 0x00007FF8EB655ED7 (ig7icd64.dll) in win32_main.exe: 0xC00000FD: Stack overflow (parameters: 0x0000000000000001, 0x000000DA846C3000).

Shader code:

const char* vs_selected =
"#version 330 core\n"
"layout (location = 0) in vec3 vec_pos;"
"layout (location = 1) in vec3 aColor;"
"layout (location = 2) in vec2 tex_coord;"
"uniform mat4 view_mat;"
"uniform mat4 proj_mat;"
"uniform vec2 image_offset;"
"uniform vec2 image_scale;"
"uniform float total_time;"
"uniform float char_num;"
"out vec2 pass_tex_coord;"
"void main()"
"{"
"pass_tex_coord = vec2(tex_coord.s * image_scale.s , tex_coord.t * image_scale.t) + image_offset;"
"gl_Position = vec4(vec_pos , 1.0f);"
"gl_Position.x += abs(sin(3*total_time)) / 50.0;"
"gl_Position.y += abs(sin(char_num + 10*total_time))/40.0;"
"}";

const char* fs_selected =
"#version 330 core\n"
"out vec4 frag_color;"
"in vec2 pass_tex_coord;"
"uniform sampler2D our_texture;"
"uniform float total_time;"
"void main()"
"{"
"    vec4 color  = texture(our_texture, pass_tex_coord) * vec4(abs(sin(2*total_time)), 0, 1, 1.0);"
"    if(color.a == 0.0) discard;"
"    frag_color = color;"
"}";

Create shader code:

GLuint create_shader_gl(const char* vertex_shader, const char* fragment_shader)
{
    GLenum err = GL_NO_ERROR;
    err =  glGetError();
    GLuint vert_shader, frag_shader, shader_id;
    
    vert_shader = glCreateShader(GL_VERTEX_SHADER);
    glShaderSource( vert_shader, 1, &vertex_shader, NULL);
    glCompileShader(vert_shader);
    
    GLint success = 0;
    glGetShaderiv(vert_shader, GL_COMPILE_STATUS, &success);
    Assert(success != GL_FALSE);
    
    frag_shader = glCreateShader(GL_FRAGMENT_SHADER);
    glShaderSource( frag_shader, 1, &fragment_shader, NULL);
    glCompileShader(frag_shader);
    
    glGetShaderiv(frag_shader, GL_COMPILE_STATUS, &success);
    Assert(success != GL_FALSE);
    
    shader_id = glCreateProgram();
    glAttachShader(shader_id, vert_shader);
    glAttachShader(shader_id, frag_shader);
    glLinkProgram(shader_id);
    glGetProgramiv(shader_id, GL_LINK_STATUS, &success);
    Assert(success != GL_FALSE);
        
    return shader_id;
}

An unhandled exception is either a driver bug or an issue elsewhere in your code (not the shaders).

For debugging issues with shaders, the first step would be to call glGetShaderInfoLog or glGetProgramInfoLog if compilation or linking fails.

Thanks for the advice. I had been using the glGetError() to try to get information, but they never provide me any errors. I have tried now tried glGetShaderInfoLog and glGetProgramInfoLog to try to get any error messages, but they don’t report any. My program crashes at glLinkProgram, so I can’t seem to extract any error messages after that point. Is there any way to definitively tell if it is a driver bug? I was able to get the program to run on another machine. The machine it crashed on it somewhat older thinkpad while the one the code ran on was newer hp labtop.

Only if you can definitively exclude the possibility of a bug in your program causing memory corruption.

The problem with memory corruption is you often “get away with it”; whether or not it affects anything depends upon what memory was corrupted and what it’s used for.

Hi, I have found somewhat of a fix, but it is a little weird. When I increase my stack size the program seems to run fine. This seems weird to be since I thought it would give me a complication error if I was going to use more memory than was required.

I have spent a little while trying to find any memory corruption issues so far, but not luck. I still suspect it may be a driver error as I was able to get the program to run on a third machine without increasing the stack size. I my graphics driver is an Intel(R) HD Graphics 4000 which I believe is somewhat old and has been discontinued. The program seems to only trip up on glLinkProgram and when certain shaders are linked. This has been a strange bug…

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.