From 61d40ae4d04a235d13c9602d36574f2186f91f4d Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Thu, 22 Oct 2020 18:21:07 +0200 Subject: [PATCH] mapi: do not call thread-unsafe dispatch getter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When not using the USE_ELF_TLS code-path, this function is thread-unsafe, because it returns u_current_table if set without consulting the ThreadSafe variable in u_current.c. There's a short period where this can cause problems, if a program uses multiple threads, but only have made a single context current so far. If the program issues OpenGL commands from the initialized thread while a new thread is setting u_current_table to __glapi_noop_table, we will return the wrong table here. It doesn't seem right to have two versions of the code that does the same anyway, so let's use the version that doesn't have this problem instead. Reviewed-by: Ian Romanick Reviewed-by: Louis-Francis Ratté-Boulianne Part-of: --- src/mapi/entry.c | 2 +- src/mapi/u_current.h | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/mapi/entry.c b/src/mapi/entry.c index 315829eb30b..7ff3c8f8c8c 100644 --- a/src/mapi/entry.c +++ b/src/mapi/entry.c @@ -67,7 +67,7 @@ entry_current_get(void) #ifdef MAPI_MODE_BRIDGE return GET_DISPATCH(); #else - return u_current_get_table(); + return u_current_get_table_internal(); #endif } diff --git a/src/mapi/u_current.h b/src/mapi/u_current.h index 8f7d222b976..e7faa878ed1 100644 --- a/src/mapi/u_current.h +++ b/src/mapi/u_current.h @@ -62,15 +62,4 @@ u_current_set_context(const void *ptr); void * u_current_get_context_internal(void); -static inline const struct _glapi_table * -u_current_get_table(void) -{ -#ifdef USE_ELF_TLS - return u_current_table; -#else - return (likely(u_current_table) ? - u_current_table : u_current_get_table_internal()); -#endif -} - #endif /* _U_CURRENT_H_ */