[ruby-opengl-devel] Crash in glGetShaderInfoLog

Ronald Pijnacker pijnacker at dse.nl
Wed Apr 11 09:26:17 EDT 2007


Jan,

> On Tuesday 10 April 2007 09:45, you wrote:
> > I tried running with your patch applied. This time it did not crash
> > anymore, but it hung the process.
> > Running in the debugger led to strange results: while stepping through
> > the xfree function, I ended up in rb_str_new.
> >
> > Since this smells like memory gone bad, I ran it though purify. This
> > warns about beyond stack write problems, but I really do not understand
> > why. I've attached a purify screenshot that shows the problem.
> >
> > Possibly there is something corrupted in the ruby-runtime, which
> > triggers these strange problems. However, I have no clue where to look.
> 
> The problem with stack corruption is it is very hard to find where exactly it 
> happens as it is usually caught much later in execution by malloc/free. It 
> may be in the ruby runtime, it may be in the fox library, it may be in our 
> bindings, but it may also be in the underlying opengl implementation 
> (drivers). I've tried to trace it on linux with valgrind, but there seems to 
> be no problem, so i'll try it tommorrow on windows installation to see if 
> thats any different. Can you try to write/run the same code without the fox 
> library (only with glut) to eliminate one of the possibilities ? Thanks.

It does not seem to matter much. Also with glut, the program seems to
hang.
I've attached the glut version of the program for you to try.

	Ronald.

-------------- next part --------------
require 'gl';   include Gl
require 'glu';  include Glu
require 'glut'; include Glut

VERTEX_SHADER_SOURCE = <<__VERTEX_SHADER_SOURCE__

void main(void)
{
    gl_Position = ftransform();
}

__VERTEX_SHADER_SOURCE__
FRAGMENT_SHADER_SOURCE = <<__FRAGMENT_SHADER_SOURCE__

void main(void)
{
    gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
}

__FRAGMENT_SHADER_SOURCE__

def init_gl_window(width = 640, height = 480)
    unless @program
        @vertex_shader = glCreateShader(GL_VERTEX_SHADER)
        @fragment_shader = glCreateShader(GL_FRAGMENT_SHADER)
        glShaderSource(@vertex_shader, VERTEX_SHADER_SOURCE)
        glShaderSource(@fragment_shader, FRAGMENT_SHADER_SOURCE)
        glCompileShader(@vertex_shader)
        ok1 = glGetShaderiv(@vertex_shader, GL_COMPILE_STATUS)
        raise unless ok1==1
        puts glGetShaderInfoLog(@vertex_shader)
        glCompileShader(@fragment_shader)
        ok2 = glGetShaderiv(@fragment_shader, GL_COMPILE_STATUS)
        raise unless ok2==1
        puts glGetShaderInfoLog(@fragment_shader)

        @program = glCreateProgram
        glAttachShader(@program, @vertex_shader)
        glAttachShader(@program, @fragment_shader)
        glLinkProgram(@program)
        ok = glGetProgramiv(@program, GL_LINK_STATUS)
        raise unless ok==1
    end

    glUseProgram(@program)
    p glGetError
end

def draw_gl_scene
    # Clear the screen and depth buffer
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    # Swap buffers for display 
    glutSwapBuffers
end

# The idle function to handle 
def idle
    glutPostRedisplay
end

# Keyboard handler to exit when ESC is typed
keyboard = lambda do |key, x, y|
    case(key)
      when 27
          glutDestroyWindow(window)
          exit(0)
      end
      glutPostRedisplay
end

# Initliaze our GLUT code
glutInit
# Setup a double buffer, RGBA color, alpha components and depth buffer
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH)
glutInitWindowSize(640, 480)
glutInitWindowPosition(0, 0)
window = glutCreateWindow("crash test")
glutDisplayFunc(method(:draw_gl_scene).to_proc)
glutIdleFunc(method(:idle).to_proc)
glutKeyboardFunc(keyboard)
init_gl_window(640, 480)
glutMainLoop()


More information about the ruby-opengl-devel mailing list