OpenGL window in GTK

I have an SDL/OpenGL window within a GTK application, and it seems to
work fine until I resize the SDL window, at which point it crashes with
an X error. The code that I have in my resize event is as follows:

SCREEN_X = allocation->width;
SCREEN_Y = allocation->height;

glViewport( 0, 0, ( GLint )SCREEN_X, ( GLint )SCREEN_Y );

gluOrtho2D(0, SCREEN_X, SCREEN_Y, 0);

Is there any way at all to get this working?