GLFW threading bug

joemue2 wrote on Friday, June 12, 2009:

There seems to be a threading bug in GLFW. My program now crashed for the second time in

1 _GLFWthread * _glfwGetThreadPointer( int ID )
2 {
3 _GLFWthread *t;
4
5 for( t = &_glfwThrd.First; t != NULL; t = t->Next )
6 {
7 if( t->ID == ID )
8 {
9 break;
10 }
11 }
12
13 return t;
14 }

at the line 7. t is not a valid pointer (was 0xeeefeeef or 0xfeeefeee). I recognized that this function is called from the new thread wrapper function _glfwNewThread. The problem might be that functions modifying _glfwThrd are atomic in main thread, but glfwGetThreadPointer might access the _glfwThrd at any time.

This bug is hard to reproduce. It occured two times for me when creating a lot of thread (~300) in a short period of time.

Is there quick workaround? Should i open a bug in the bug tracker?

Regards,
Joe