about summary refs log tree commit diff
path: root/linuxthreads/cancel.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-04-11 21:29:54 +0000
committerUlrich Drepper <drepper@redhat.com>2001-04-11 21:29:54 +0000
commit95fe9d959f956c8b31a3bd8801ea9dfe475842a5 (patch)
treef12d85c19d5e186d8771e586d192b030efe0a641 /linuxthreads/cancel.c
parent8ee355155102ad7c2e473f179f4879c6e468f19e (diff)
downloadglibc-95fe9d959f956c8b31a3bd8801ea9dfe475842a5.tar.gz
glibc-95fe9d959f956c8b31a3bd8801ea9dfe475842a5.tar.xz
glibc-95fe9d959f956c8b31a3bd8801ea9dfe475842a5.zip
Update.
2001-04-11  Ulrich Drepper  <drepper@redhat.com>

	* cancel.c (_pthread_cleanup_push): Catch invalid __prev buffer
	and remove it.
	(_pthread_cleanup_push_defer): Likewise.

	* tst-cancel.c (main): Fix loop printing cleanup output.
Diffstat (limited to 'linuxthreads/cancel.c')
-rw-r--r--linuxthreads/cancel.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/linuxthreads/cancel.c b/linuxthreads/cancel.c
index ed67a6845f..32ad17c838 100644
--- a/linuxthreads/cancel.c
+++ b/linuxthreads/cancel.c
@@ -125,6 +125,18 @@ void _pthread_cleanup_push(struct _pthread_cleanup_buffer * buffer,
   buffer->__routine = routine;
   buffer->__arg = arg;
   buffer->__prev = THREAD_GETMEM(self, p_cleanup);
+  if (buffer->__prev != NULL)
+    {
+#if _STACK_GROWS_DOWN
+      if ((char *) buffer >= (char *) buffer->__prev)
+	buffer->__prev = NULL;
+#elif _STACK_GROWS_UP
+      if ((char *) buffer <= (char *) buffer->__prev)
+	buffer->__prev = NULL;
+#else
+# error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
+#endif
+    }
   THREAD_SETMEM(self, p_cleanup, buffer);
 }
 
@@ -144,6 +156,16 @@ void _pthread_cleanup_push_defer(struct _pthread_cleanup_buffer * buffer,
   buffer->__arg = arg;
   buffer->__canceltype = THREAD_GETMEM(self, p_canceltype);
   buffer->__prev = THREAD_GETMEM(self, p_cleanup);
+  if (buffer->__prev != NULL)
+    {
+#if _STACK_GROWS_DOWN
+      if ((char *) buffer >= (char *) buffer->__prev)
+	buffer->__prev = NULL;
+#elif _STACK_GROWS_UP
+      if ((char *) buffer <= (char *) buffer->__prev)
+	buffer->__prev = NULL;
+#endif
+    }
   THREAD_SETMEM(self, p_canceltype, PTHREAD_CANCEL_DEFERRED);
   THREAD_SETMEM(self, p_cleanup, buffer);
 }
@@ -174,8 +196,6 @@ void __pthread_perform_cleanup(char *currentframe)
 #elif _STACK_GROWS_UP
       if ((char *) c >= currentframe)
 	break;
-#else
-# error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
 #endif
       c->__routine(c->__arg);
     }