summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Brenneman <kbrenneman@nvidia.com>2016-04-01 09:18:33 -0600
committerKyle Brenneman <kbrenneman@nvidia.com>2016-04-01 09:18:33 -0600
commitb7d75429677eecc00c3701aaa4deac1304bc51ff (patch)
tree34c7eda714b51515e8d3b4bdb25a37bb4bbd0562
parentc5bcda3b848fe52d6ae6ef25c917431c06d62d27 (diff)
GLX: Don't call into the vendor library from __glXFini.
By the time __glXFini is called, the destructors in the vendor libraries may have already been called, so it's not safe to call any functions in the vendor library. __glXFini will now check for a fork and go through fork recovery, but it won't call __glDispatchCheckMultithreaded. If there was a current context, then __glDispatchCheckMultithreaded might call the vendor's thread attach callback.
-rw-r--r--src/GLX/libglx.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/GLX/libglx.c b/src/GLX/libglx.c
index 840edc1..9d434c3 100644
--- a/src/GLX/libglx.c
+++ b/src/GLX/libglx.c
@@ -1937,12 +1937,11 @@ int AtomicDecrementClampAtZero(int volatile *val)
static void __glXResetOnFork(void);
-/*
- * Perform checks that need to occur when entering any GLX entrypoint.
- * Currently, this only detects whether a fork occurred since the last
- * entrypoint was called, and performs recovery as needed.
+/*!
+ * Checks to see if a fork occurred since the last GLX entrypoint was called,
+ * and performs recovery if needed.
*/
-void __glXThreadInitialize(void)
+static void CheckFork(void)
{
volatile static int g_threadsInCheck = 0;
volatile static int g_lastPid = -1;
@@ -1974,7 +1973,15 @@ void __glXThreadInitialize(void)
sched_yield();
}
}
+}
+/*!
+ * Handles any common tasks that need to occur at the beginning of any GLX
+ * entrypoint.
+ */
+void __glXThreadInitialize(void)
+{
+ CheckFork();
__glDispatchCheckMultithreaded();
}
@@ -2078,8 +2085,14 @@ void __attribute__ ((destructor)) __glXFini(void)
void _fini(void)
#endif
{
+ /*
+ * Note that the dynamic linker may have already called the destructors for
+ * the vendor libraries. As a result, we can't do anything here that would
+ * try to call into any vendor library.
+ */
+
/* Check for a fork before going further. */
- __glXThreadInitialize();
+ CheckFork();
/*
* If libGLX owns the current thread state, lose current