Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Feb 2012 13:02:25 +0100
From:      Ivan Voras <ivoras@freebsd.org>
To:        Garrett Cooper <yanegomi@gmail.com>
Cc:        freebsd-hackers@freebsd.org, Xin LI <delphij@delphij.net>, davidxu@freebsd.org, Jan Mikkelsen <janm-freebsd-hackers@transactionware.com>
Subject:   Re: sem(4) lockup in python?
Message-ID:  <CAF-QHFVADLkduLH1AG_hSZeDtDVCC=FkqZxbxrsMY3Y3%2BsMZ8A@mail.gmail.com>
In-Reply-To: <CAGH67wT3HuxPHUXeTib0qJNH%2BO5snn3Eiim1bfj8LewYoKdXdA@mail.gmail.com>
References:  <jejrbe$or8$1@dough.gmane.org> <201201110806.30620.jhb@freebsd.org> <CAF-QHFWFvYTPeM68Mk%2BOYVX--MNhKOJ2o1GF9ZOsBmtiC5fYFQ@mail.gmail.com> <CAGH67wRsek2-WY_ETW6QEER1r5dDXLXfDjbzpHMjtv059Y8cJw@mail.gmail.com> <5D37298B-9D68-4F0F-8AAB-E8F2DBB9D9C3@transactionware.com> <CAGH67wT3HuxPHUXeTib0qJNH%2BO5snn3Eiim1bfj8LewYoKdXdA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
On 5 February 2012 11:44, Garrett Cooper <yanegomi@gmail.com> wrote:

>
>    'make MAKE_JOBS_NUMBER=1' is the workground used right now..

David Xu suggested that it is a bug in Python - it doesn't set
process-shared attribute when it calls sem_init(), but i've tried
patching it (replacing the port patchfile file the one I've attached)
and I still get the hang.

[-- Attachment #2 --]
--- Python/thread_pthread.h.orig	2012-02-05 12:46:07.000000000 +0100
+++ Python/thread_pthread.h	2012-02-05 12:44:58.000000000 +0100
@@ -38,13 +38,18 @@
 #endif
 #endif
 
+#ifdef __FreeBSD__
+#include <osreldate.h>
+#endif
+
 /* The POSIX spec says that implementations supporting the sem_*
    family of functions must indicate this by defining
    _POSIX_SEMAPHORES. */
 #ifdef _POSIX_SEMAPHORES
 /* On FreeBSD 4.x, _POSIX_SEMAPHORES is defined empty, so
    we need to add 0 to make it work there as well. */
-#if (_POSIX_SEMAPHORES+0) == -1
+#if defined(__FreeBSD__) && __FreeBSD_version < 701104 && \
+    (_POSIX_SEMAPHORES+0) == -1
 #define HAVE_BROKEN_POSIX_SEMAPHORES
 #else
 #include <semaphore.h>
@@ -56,7 +61,6 @@
    in default setting.  So the process scope is preferred to get
    enough number of threads to work. */
 #ifdef __FreeBSD__
-#include <osreldate.h>
 #if __FreeBSD_version >= 500000 && __FreeBSD_version < 504101
 #undef PTHREAD_SYSTEM_SCHED_SUPPORTED
 #endif
@@ -161,6 +165,7 @@
 {
     pthread_t th;
     int status;
+    sigset_t set, oset;
 #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
     pthread_attr_t attrs;
 #endif
@@ -189,6 +194,8 @@
 #if defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
     pthread_attr_setscope(&attrs, PTHREAD_SCOPE_SYSTEM);
 #endif
+    sigfillset(&set);
+    SET_THREAD_SIGMASK(SIG_BLOCK, &set, &oset);
 
     status = pthread_create(&th,
 #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
@@ -200,6 +207,7 @@
                              (void *)arg
                              );
 
+    SET_THREAD_SIGMASK(SIG_SETMASK, &oset, NULL);
 #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
     pthread_attr_destroy(&attrs);
 #endif
@@ -265,7 +273,7 @@
     lock = (sem_t *)malloc(sizeof(sem_t));
 
     if (lock) {
-        status = sem_init(lock,0,1);
+        status = sem_init(lock,1,1);
         CHECK_STATUS("sem_init");
 
         if (error) {

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAF-QHFVADLkduLH1AG_hSZeDtDVCC=FkqZxbxrsMY3Y3%2BsMZ8A>