Module Name: src
Committed By: drochner
Date: Wed Apr 1 10:13:24 UTC 2009
Modified Files:
src/lib/libpthread: pthread.c
Log Message:
Fix the comparision function used by the red-black tree global thread list
implementation:
-don't return a difference, this can overflow
-don't try to substract typed pointers which don't belong to the
same object, this gives undefined results
This fixes instabilities of programs which use more than a handful
of threads, eg spuriously failing pthread_join().
To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/lib/libpthread/pthread.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libpthread/pthread.c
diff -u src/lib/libpthread/pthread.c:1.108 src/lib/libpthread/pthread.c:1.109
--- src/lib/libpthread/pthread.c:1.108 Mon Mar 30 21:32:51 2009
+++ src/lib/libpthread/pthread.c Wed Apr 1 10:13:24 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread.c,v 1.108 2009/03/30 21:32:51 ad Exp $ */
+/* $NetBSD: pthread.c,v 1.109 2009/04/01 10:13:24 drochner Exp $ */
/*-
* Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread.c,v 1.108 2009/03/30 21:32:51 ad Exp $");
+__RCSID("$NetBSD: pthread.c,v 1.109 2009/04/01 10:13:24 drochner Exp $");
#define __EXPOSE_STACK 1
@@ -1275,7 +1275,13 @@
static int
pthread__cmp(struct __pthread_st *a, struct __pthread_st *b)
{
- return b - a;
+
+ if ((uintptr_t)a < (uintptr_t)b)
+ return (-1);
+ else if (a == b)
+ return 0;
+ else
+ return 1;
}
RB_GENERATE_STATIC(__pthread__alltree, __pthread_st, pt_alltree, pthread__cmp)
#endif