GLSL linker info log garbled

I’m testing out OpenGL shader programming, and am having trouble linking my shader program.

When I run my program, which compiles and links a simple shader program, checking for errors and outputting any resulting log messages, I get this output on the console:

Ç─2X¨æ☻

Edit: removed code tags around the above that were mangling it /Edit

This seems to be coming from the linking step, as slightly modifying the shader code to give a compile error gets me this:

ERROR: 0:1: 'q' : syntax error parse error


Ç─6X¨ø☻:1: 'q' : syntax error parse error

The relevant source code in C++ is included below.

Any ideas what I’m doing wrong? I’m not sure what to search for, since I’m not getting a usable error message. Searching for the various gl commands just gives me examples on how to use them, which I’m attempting to follow.

Thanks.

        GLuint fragment_shader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);

        const char* shader_string =
            "void main() {"
            "    gl_FragColor = vec4(0.4, 0.4, 0.8, 1.0);"
            "}";

        glShaderSourceARB(fragment_shader, 1, &shader_string, NULL);
        glCompileShader(fragment_shader);

        GLint fragment_shader_compiled = 0;
        glGetObjectParameterivARB(fragment_shader, GL_OBJECT_COMPILE_STATUS_ARB, &fragment_shader_compiled);

        if (!fragment_shader_compiled) {
            boost::scoped_array<char> fragment_compile_output(new char[512]);
            glGetInfoLogARB(fragment_shader, 512., NULL, fragment_compile_output.get());
            std::cerr << fragment_compile_output.get() << std::endl;
        }

        glAttachObjectARB(blur_program, fragment_shader);
        glLinkProgramARB(blur_program);

        GLint fragment_shader_linked = 0;
        glGetObjectParameterivARB(blur_program, GL_OBJECT_LINK_STATUS_ARB, &fragment_shader_linked);

        if (!fragment_shader_linked) {
            boost::scoped_array<char> fragment_link_output(new char[512]);
            glGetInfoLogARB(blur_program, 512, NULL, fragment_link_output.get());
            std::cerr << fragment_link_output.get() << std::endl;
        }

seems like not OpenGL but how you handle the output. in other words the string format you construct is messed up giving you some random memory values or your shader contains those values for some reasons. a debug session is in order.

I replaced the boost::scoped_array<char> with char log_buffer[512]. Without a syntax error in the shader code, I get something like:

d▀
:spades:▄/■:clubs:

Edit: changed the above to display what I actually get, not the forum software’s reinterpretation. /Edit

If I add a syntax error to the shader, I get

ERROR: 0:1: 'q' : syntax error parse error

ERROR: 0:1: 'q' : syntax error parse error

Could it still be a problem with the buffer? Any other ideas or suggestions?

        GLuint fragment_shader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);

        const char* shader_string =
            "void main() {"
            "    gl_FragColor = vec4(0.4, 0.4, 0.8, 1.0);"
            "}";


        char log_buffer[512];

        glShaderSourceARB(fragment_shader, 1, &shader_string, NULL);
        glCompileShader(fragment_shader);

        GLint fragment_shader_compiled = 0;
        glGetObjectParameterivARB(fragment_shader, GL_OBJECT_COMPILE_STATUS_ARB, &fragment_shader_compiled);

        if (!fragment_shader_compiled) {
            glGetInfoLogARB(fragment_shader, 512., NULL, log_buffer);
            std::cerr << log_buffer << std::endl;
        }

        glAttachObjectARB(blur_program, fragment_shader);
        glLinkProgramARB(blur_program);

        GLint fragment_shader_linked = 0;
        glGetObjectParameterivARB(blur_program, GL_OBJECT_LINK_STATUS_ARB, &fragment_shader_linked);

        if (!fragment_shader_linked) {
            glGetInfoLogARB(blur_program, 512, NULL, log_buffer);
            std::cerr << log_buffer << std::endl;
        }

        delete[] log_buffer;

can’t follow. with intentional error in your shader code you get a reasonable error message. with no errors you get the trashed error message?
what gfx card and driver version you developing on?
btw, why do you delete log_buffer?

Yes; the compile error message looks reasonable.

with no errors you get the trashed error message?

There is apparently an error in the linking stage, but the linking error message is garbled.

what gfx card and driver version you developing on?

An Intel X3100 GMA laptop onboard card, which is supposed to support OpenGl 2.0. Driver version 7.15.10.1537 dated 29/07/2008 according to Windows Vista. As far as I can tell, this is up-to-date.

btw, why do you delete log_buffer?

I forgot it wasn’t allocated with new.

Intel… you know, any 3D graphics developer hates Intel for their “graphics” cards. You might want to try your program on some other PC with an ATI or nVidia card and check, whether the same thing happens there, too.

It seems like it is a simple overflow to me, but I didnt really read much of the code… try adding a null terminator ‘\0’ to the end, I had to do this to stop such a error in one of my parsers (before I realized that you dont need to filter out comments xDD)

At the end of the shader text? (Isn’t it already a null-terminated string?) Or at the end of the buffer?

I tried initializing the log buffer to all ‘.’ except the last char, which is set to ‘\0’.

        GLuint fragment_shader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);

        const char* shader_string =
            "void main() {"
            "    gl_FragColor = vec4(0.4, 0.4, 0.8, 1.0);"
            "}";

        const unsigned int LOG_BUFFER_SIZE = 50;
        char log_buffer[LOG_BUFFER_SIZE];
        for (unsigned int i = 0; i < LOG_BUFFER_SIZE; ++i)
            log_buffer[i] = '.';
        log_buffer[LOG_BUFFER_SIZE - 1] = '\0';

        glShaderSourceARB(fragment_shader, 1, &shader_string, NULL);
        glCompileShader(fragment_shader);

        GLint fragment_shader_compiled = 0;
        glGetObjectParameterivARB(fragment_shader, GL_OBJECT_COMPILE_STATUS_ARB, &fragment_shader_compiled);

        if (!fragment_shader_compiled) {
            glGetInfoLogARB(fragment_shader, LOG_BUFFER_SIZE, NULL, log_buffer);
            std::cerr << "Shader Compile Error: " << log_buffer << std::endl;
        }

        glAttachObjectARB(blur_program, fragment_shader);
        glLinkProgramARB(blur_program);

        GLint fragment_shader_linked = 0;
        glGetObjectParameterivARB(blur_program, GL_OBJECT_LINK_STATUS_ARB, &fragment_shader_linked);

        if (!fragment_shader_linked) {
            glGetInfoLogARB(blur_program, LOG_BUFFER_SIZE, NULL, log_buffer);
            std::cerr << "Shader Link Error: " << log_buffer << std::endl;

            std::cerr << std::endl;

            for (unsigned int i = 0; i < LOG_BUFFER_SIZE; ++i)
                std::cout << static_cast<int>(log_buffer[i]) << ", ";
        }

I now get the output below, suggesting my attempts to get the linker error log isn’t working at all. Is my method of doing so correct? ( glGetInfoLogARB(blur_program, LOG_BUFFER_SIZE, NULL, log_buffer); )

Current output:

Shader Link Error: …

46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
46, 46, 46, 46, 46, 46, 46, 46, 46, 0,

Third parameter should not be NULL ! Indeed the log_buffer is NOT zero terminated. That is why cherryyosh gave you a good advice.
"OpenGL provides a way to get any error messages generated by the compiler with the glGetInfoLogARB function. It takes four parameters: the object handle, the maximum buffer length to use, a pointer to an integer which it will update with the output string length, and a character buffer which it will fill with the error message. There will be no terminating 0 on the string it outputs (which is why it gives you the length). The length of this string will be 0 if there were no errors. The following is dirty little example of one call to this function that would take place after compiling the shader_vert object.

char infobuffer[1000];
int infobufferlen = 0;
glGetInfoLogARB(shader_vert, 999, &infobufferlen, infobuffer);
infobuffer[infobufferlen] = 0;
"

Honestly I cant say.I’ve never made a shader loader from a string, rather I just load them from files, and nothing stands out besides your use of ARB (if you can use 2.1 and glsl 1.2 then you dont need those )

Found my problem, I think.

I was missing a call to program = glCreateProgramObjectARB() before program was passed to glAttachObjectARB().

This explains why only the linking step was failing, and why there wasn’t any log error information to retreive. It’s noted earlier in the thread that I was able to get the log information about compile errors using essentially the same code that wasn’t giving anything for the link error.

Thanks for the help… I’ll probably need more later.

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