summaryrefslogtreecommitdiff
path: root/libpthread
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2006-11-09 08:07:43 +0000
committerMike Frysinger <vapier@gentoo.org>2006-11-09 08:07:43 +0000
commitf0d13fdd5d5f11847ce6d5b148e167e7999e075e (patch)
treecb28f4b793f771dc39ce96ebf168714e92797058 /libpthread
parent4776eaf3e312ab56e7fd2ab22b4e88f6f2dd10a4 (diff)
backport from upstream:
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.
Diffstat (limited to 'libpthread')
-rw-r--r--libpthread/linuxthreads.old/cancel.c12
-rw-r--r--libpthread/linuxthreads.old/internals.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/libpthread/linuxthreads.old/cancel.c b/libpthread/linuxthreads.old/cancel.c
index f354c2a38..25b098dd5 100644
--- a/libpthread/linuxthreads.old/cancel.c
+++ b/libpthread/linuxthreads.old/cancel.c
@@ -26,6 +26,14 @@
extern void __rpc_thread_destroy(void);
#endif
+#ifdef _STACK_GROWS_DOWN
+# define FRAME_LEFT(frame, other) ((char *) frame >= (char *) other)
+#elif _STACK_GROWS_UP
+# define FRAME_LEFT(frame, other) ((char *) frame <= (char *) other)
+#else
+# error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
+#endif
+
int pthread_setcancelstate(int state, int * oldstate)
{
@@ -128,6 +136,8 @@ 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 && FRAME_LEFT (buffer, buffer->__prev))
+ buffer->__prev = NULL;
THREAD_SETMEM(self, p_cleanup, buffer);
}
@@ -147,6 +157,8 @@ 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 && FRAME_LEFT (buffer, buffer->__prev))
+ buffer->__prev = NULL;
THREAD_SETMEM(self, p_canceltype, PTHREAD_CANCEL_DEFERRED);
THREAD_SETMEM(self, p_cleanup, buffer);
}
diff --git a/libpthread/linuxthreads.old/internals.h b/libpthread/linuxthreads.old/internals.h
index f1d5db16b..bd4d8ae13 100644
--- a/libpthread/linuxthreads.old/internals.h
+++ b/libpthread/linuxthreads.old/internals.h
@@ -24,6 +24,7 @@
#include <setjmp.h>
#include <signal.h>
#include <unistd.h>
+#include <bits/stackinfo.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "pt-machine.h"