Hi, I'm trying to make Gauche Scheme work on OpenBSD but I'm hitting a wall debugging it. The problem is that thread tests get stuck. Debugging the issue would indicate that the thread test causes threads to suspend and sem_wait blocks forever. Gauche uses internal copy of boehm-gc for option -DDONT_ADD_BYTE_AT_END.
Here's the original mail thread on Gauche mailing list: https://sourceforge.net/p/gauche/mailman/message/34969290/ So steps to reproduce this issue: 1) download and extract Gauche from http://prdownloads.sourceforge.net/gauche/Gauche-0.9.4.tgz tar xzf Gauche-0.9.4.tgz cd Gauche-0.9.4 2) apply GC patches from /usr/ports/devel/boehm-gc for p in /usr/ports/devel/boehm-gc/patches do patch < $p done 3) add following patch to and run autoconf $OpenBSD$ --- configure.ac.orig Sun Jul 20 00:11:12 2014 +++ configure.ac Thu Mar 24 20:26:10 2016 @@ -199,6 +199,13 @@ case $GAUCHE_THREAD_TYPE in THREADDLLIBS="-lpthread -lrt" GAUCHE_THREAD_TYPE=pthreads ;; + *-*-openbsd*) + AC_DEFINE(GC_OPENBSD_THREADS,1,[Define to use OpenBSD threads]) + AC_DEFINE(_PTHREADS) + THREADLIBS="-lpthread" + THREADDLLIBS="-lpthread" + GAUCHE_THREAD_TYPE=pthreads + ;; *-*-solaris*) AC_DEFINE(GC_SOLARIS_THREADS,1,[Define to use Solaris threads]) AC_DEFINE(GC_SOLARIS_PTHREADS,1,[Define to use Solaris pthreads]) 4) add following diff to src/main.c --- a/src/main.c +++ b/src/main.c @@ -289,6 +289,10 @@ static void sig_setup(void) sigdelset(&set, SIGUSR1); /* used by GC to stop the world */ sigdelset(&set, SIGUSR2); /* used by GC to restart the world */ #endif /*GC_FREEBSD_THREADS*/ +#if defined(GC_OPENBSD_THREADS) + sigdelset(&set, SIGXFSZ); + sigdelset(&set, SIGXCPU); +#endif Scm_SetMasterSigmask(&set); } 5) run ./configure --enable-threads=pthreads && make 6) to run the thread test, add following to debug.scm and run `./src/gosh -ftest ./debug.scm` (use gauche.threads) (print (let ([a (atom 0)] [ts '()]) (dotimes [n 30] (push! ts (thread-start! (make-thread (^[] (dotimes [m 10] (atomic-update! a (pa$ + 1)))))))) (for-each thread-join! ts) (atom-ref a))) As seem from the mail thread, the issue seems to be that on OpenBSD the thread test get stuck on sem_wait call on gc/pthread_stop_world.c:645 for some reason. Anyone have idea what could be the cause and how to proceed debugging this? Timo