Devin Hussey wrote:
regexec.c calls lock_unlock, which is a macro that calls, from glthread/lock.h 
glthread_lock_lock, which calls pthread_in_use, which is defined as 
(pthread_cancel != NULL).

Thanks for the explanation. Does the attached Gnulib patch fix things for you?

>From 927d36f6cdbda0a4c545e399b2e9b334f83d4497 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Thu, 10 May 2018 01:03:49 -0700
Subject: [PROPOSED] pthread: detect via pthread_detach

Formerly the code used pthread_cancel, but Android lacks
pthread_cancel.  Problem reported by Devin Hussey in:
https://lists.gnu.org/r/bug-gnulib/2018-05/msg00062.html
* lib/glthread/cond.h (pthread_in_use):
* lib/glthread/lock.h (pthread_in_use):
* lib/glthread/thread.h (pthread_in_use):
* lib/glthread/tls.h (pthread_in_use):
Use pthread_detach, not pthread_cancel.
---
 ChangeLog             | 12 ++++++++++++
 lib/glthread/cond.h   |  4 ++--
 lib/glthread/lock.h   |  9 +++++----
 lib/glthread/thread.h |  4 ++--
 lib/glthread/tls.h    |  4 ++--
 5 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 420426fe1..c01b7d9e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2018-05-10  Paul Eggert  <egg...@cs.ucla.edu>
+
+	pthread: detect via pthread_detach
+	Formerly the code used pthread_cancel, but Android lacks
+	pthread_cancel.  Problem reported by Devin Hussey in:
+	https://lists.gnu.org/r/bug-gnulib/2018-05/msg00062.html
+	* lib/glthread/cond.h (pthread_in_use):
+	* lib/glthread/lock.h (pthread_in_use):
+	* lib/glthread/thread.h (pthread_in_use):
+	* lib/glthread/tls.h (pthread_in_use):
+	Use pthread_detach, not pthread_cancel.
+
 2018-05-09  Paul Eggert  <egg...@cs.ucla.edu>
 
 	af_alg: fix my typo in afalg_buffer
diff --git a/lib/glthread/cond.h b/lib/glthread/cond.h
index 54040ffc5..5d6063e63 100644
--- a/lib/glthread/cond.h
+++ b/lib/glthread/cond.h
@@ -114,8 +114,8 @@ extern int glthread_in_use (void);
 #  endif
 
 #  if !PTHREAD_IN_USE_DETECTION_HARD
-#   pragma weak pthread_cancel
-#   define pthread_in_use() (pthread_cancel != NULL)
+#   pragma weak pthread_detach
+#   define pthread_in_use() (pthread_detach != NULL)
 #  endif
 
 # else
diff --git a/lib/glthread/lock.h b/lib/glthread/lock.h
index dd8e1f860..6d93742da 100644
--- a/lib/glthread/lock.h
+++ b/lib/glthread/lock.h
@@ -149,17 +149,18 @@ extern int glthread_in_use (void);
 #  endif
 
 #  if !PTHREAD_IN_USE_DETECTION_HARD
-    /* On most platforms, pthread_cancel or pthread_kill can be used to
+    /* On most platforms, pthread_create or pthread_kill can be used to
        determine whether libpthread is in use.
        On newer versions of FreeBSD, however, this is no longer possible,
-       because pthread_cancel and pthread_kill got added to libc.  Therefore
+       because pthread_create and pthread_kill got added to libc.
+       Presumably pthread_detach is similar.  Therefore
        use pthread_create to test whether libpthread is in use.  */
 #   if defined __FreeBSD__ || defined __DragonFly__ /* FreeBSD */
 #    pragma weak pthread_create
 #    define pthread_in_use() (pthread_create != NULL)
 #   else /* glibc, NetBSD, OpenBSD, IRIX, OSF/1, Solaris */
-#    pragma weak pthread_cancel
-#    define pthread_in_use() (pthread_cancel != NULL)
+#    pragma weak pthread_detach
+#    define pthread_in_use() (pthread_detach != NULL)
 #   endif
 #  endif
 
diff --git a/lib/glthread/thread.h b/lib/glthread/thread.h
index d8098c4f8..32ad22f86 100644
--- a/lib/glthread/thread.h
+++ b/lib/glthread/thread.h
@@ -149,8 +149,8 @@ extern int glthread_in_use (void);
 #  endif
 
 #  if !PTHREAD_IN_USE_DETECTION_HARD
-#   pragma weak pthread_cancel
-#   define pthread_in_use() (pthread_cancel != NULL)
+#   pragma weak pthread_detach
+#   define pthread_in_use() (pthread_detach != NULL)
 #  endif
 
 # else
diff --git a/lib/glthread/tls.h b/lib/glthread/tls.h
index 12bf6d5c9..2d3494520 100644
--- a/lib/glthread/tls.h
+++ b/lib/glthread/tls.h
@@ -76,8 +76,8 @@ extern int glthread_in_use (void);
 #  endif
 
 #  if !PTHREAD_IN_USE_DETECTION_HARD
-#   pragma weak pthread_cancel
-#   define pthread_in_use() (pthread_cancel != NULL)
+#   pragma weak pthread_detach
+#   define pthread_in_use() (pthread_detach != NULL)
 #  endif
 
 # else
-- 
2.17.0

Reply via email to