Hi,

I am reading ThreadSafe parts of glapi.c, and they do not seem to be
thread safe to me.  This is the case when THREADS is defined while
GLX_USE_TLS is not.

There are two races I can see so far.  First, if multiple threads are in
_glapi_check_multithread at roughly the same time, they might all be
regard as firstCall.  ThreadSafe will not be set in such case.  This can
be solved by making _glapi_check_multithread atomic (by mutex).

The second race is in GET_CURRENT_CONTEXT.  In the small time gap
between _glapi_Context is tested non-NULL and it is returned, a second
thread might be in _glapi_check_multithread and set _glapi_Context to
NULL.  This might be solved by testing ThreadSafe in GET_CURRENT_CONTEXT
to decide where to get current context.  In this case, _glapi_Context
must not (and there is no need to) be reset to NULL after ThreadSafe is
set, and ThreadSafe will be made global.

I am about to work on them, but it would be great to hear some
suggestions.

-- 
Regards,
olv

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to