Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libpthread Change the behavior of pthread_equal()
details: https://anonhg.NetBSD.org/src/rev/4b062fbe6c9c
branches: trunk
changeset: 744639:4b062fbe6c9c
user: kamil <kamil%NetBSD.org@localhost>
date: Sat Feb 08 17:06:03 2020 +0000
description:
Change the behavior of pthread_equal()
On error when not aborting, do not return EINVAL as it has a side effect
of being interpreted as matching threads. For invalid threads return
unmatched.
Check pthreads for NULL, before accessing pt_magic field. This avoids
faults on comparision with a NULL pointer.
This behavior is in the scope of UB, but should be easier to deal with
buggy software.
diffstat:
lib/libpthread/pthread.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diffs (34 lines):
diff -r c4648db21980 -r 4b062fbe6c9c lib/libpthread/pthread.c
--- a/lib/libpthread/pthread.c Sat Feb 08 14:35:47 2020 +0000
+++ b/lib/libpthread/pthread.c Sat Feb 08 17:06:03 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread.c,v 1.163 2020/02/05 14:56:04 ryoon Exp $ */
+/* $NetBSD: pthread.c,v 1.164 2020/02/08 17:06:03 kamil Exp $ */
/*-
* Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008, 2020
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread.c,v 1.163 2020/02/05 14:56:04 ryoon Exp $");
+__RCSID("$NetBSD: pthread.c,v 1.164 2020/02/08 17:06:03 kamil Exp $");
#define __EXPOSE_STACK 1
@@ -770,11 +770,11 @@
if (__predict_false(__uselibcstub))
return __libc_thr_equal_stub(t1, t2);
- pthread__error(EINVAL, "Invalid thread",
- t1->pt_magic == PT_MAGIC);
+ pthread__error(0, "Invalid thread",
+ (t1 != NULL) && (t1->pt_magic == PT_MAGIC));
- pthread__error(EINVAL, "Invalid thread",
- t2->pt_magic == PT_MAGIC);
+ pthread__error(0, "Invalid thread",
+ (t2 != NULL) && (t2->pt_magic == PT_MAGIC));
/* Nothing special here. */
return (t1 == t2);
Home |
Main Index |
Thread Index |
Old Index