Shared objects destruction issue

Hi,

I got a gl error when I try to destroy a shader object.The application creates several contexts which are shared using a common context. So, I’m able to use shader and program objects across the different contexts. There is only one thread.

When the application is finalizing, all contexts, except the common one, are destroyed. After that, all previously created GLSL shaders are destroyed, while the common context is active. The openGL error occurs when I try to destroy last used shader objects (glIsShader returns false) whereas I was able to destroy program object.

My debug trace may be more explicit. I trace all shader creations/destructions.



/////////////////////////////////
//Context creation and sharing //
//0x10001 is the common context//
/////////////////////////////////
sharing 0x00010001 and 0x00010003 -- OK
sharing 0x00010001 and 0x00010004 -- OK

/////////////////////////
//GLSL Shaders creation//
/////////////////////////
Current context : 0x00010003
Create shader : 0x1
Shader object : 0x1 is valid in context 0x00010001
Shader object : 0x1 is valid in context 0x00010003
Shader object : 0x1 is valid in context 0x00010004

Current context : 0x00010003
Create shader : 0x2
Shader object : 0x2 is valid in context 0x00010001
Shader object : 0x2 is valid in context 0x00010003
Shader object : 0x2 is valid in context 0x00010004

Current Context : 0x 00010003
Creating Program : 0x3, attaching : 0x1 0x2

Current context : 0x00010004
Create shader : 0x4
Shader object : 0x4 is valid in context 0x00010001
Shader object : 0x4 is valid in context 0x00010003
Shader object : 0x4 is valid in context 0x00010004

Current context : 0x00010004
Create shader : 0x5
Shader object : 0x5 is valid in context 0x00010001
Shader object : 0x5 is valid in context 0x00010003
Shader object : 0x5 is valid in context 0x00010004

Current Context : 0x 00010004
Creating Program : 0x6, attaching : 0x4 0x5

Current context : 0x00010003
Create shader : 0x7
Shader object : 0x7 is valid in context 0x00010001
Shader object : 0x7 is valid in context 0x00010003
Shader object : 0x7 is valid in context 0x00010004

Current context : 0x00010003
Create shader : 0x8
Shader object : 0x8 is valid in context 0x00010001
Shader object : 0x8 is valid in context 0x00010003
Shader object : 0x8 is valid in context 0x00010004

Current Context : 0x 00010003
Creating Program : 0x9, attaching : 0x7 0x8

Current context : 0x00010004
Create shader : 0xa
Shader object : 0xa is valid in context 0x00010001
Shader object : 0xa is valid in context 0x00010003
Shader object : 0xa is valid in context 0x00010004

Current context : 0x00010004
Create shader : 0xb
Shader object : 0xb is valid in context 0x00010001
Shader object : 0xb is valid in context 0x00010003
Shader object : 0xb is valid in context 0x00010004

Current Context : 0x 00010004
Creating Program : 0xc, attaching : 0xa 0xb


////////////////////////////////////////
//Do some openGL calls                //
//Just before the context destructions//
//each one has a program object in use//
//....                                //
////////////////////////////////////////

///////////////////////
//Destroying Contexts//
///////////////////////
Destroying context 0x00010003
Destroying context 0x00010004


///////////////////////////////////////////////
//The common context is the current one      //
//For this GLSL shader the destruction is OK //
///////////////////////////////////////////////
GL Context : 0x00010001
Destroying program object 0x6 -- Valid Program
Attached shaders : 0x4 -- Valid Shader 0x5 -- Valid Shader
-------
GL Context : 0x00010001
DESTROYING shader object : 0x4
Shader object : 0x4 is valid in context 0x00010001
GL Context : 0x00010001
DESTROYING shader object : 0x5
Shader object : 0x5 is valid in context 0x00010001
///////////////////////////////////////////////
//For this GLSL shader the destruction failed//
///////////////////////////////////////////////
GL Context : 0x00010001
Destroying program object 0xc -- Valid Program
Attached shaders : 0xa -- Not a Valid Shader 0xb -- Not a Valid Shader
-------
GL Context : 0x00010001
DESTROYING shader object : 0xa
Shader object : 0xa is not valid in context 0x00010001
OpenGL error : GL_INVALID_VALUE : A numeric argument is out of range. The offend
ing function is ignored, having no side effect other than to set the error flag.

The solution I found consists in calling glUseProgram(0) before destroying the context.
Has someone ever got this problem, or did I miss something into the specifications ?

Thanks in advance,
Regards,
Laurent


OS : Win XP 32 bits
GPU : ATI HD4850, Driver : 10.1 (last version)

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