Revision: 75568
http://sourceforge.net/p/brlcad/code/75568
Author: starseeker
Date: 2020-04-23 04:11:30 +0000 (Thu, 23 Apr 2020)
Log Message:
-----------
Make the bu_bomb message a bit more informative, since that's often times all
we can see. It reveals that the BSD failure is an EPERM error:
https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_mutex_lock.html
Modified Paths:
--------------
brlcad/trunk/doc/bsd_semaphore_bug.txt
brlcad/trunk/src/libbu/semaphore.c
Modified: brlcad/trunk/doc/bsd_semaphore_bug.txt
===================================================================
--- brlcad/trunk/doc/bsd_semaphore_bug.txt 2020-04-23 03:34:04 UTC (rev
75567)
+++ brlcad/trunk/doc/bsd_semaphore_bug.txt 2020-04-23 04:11:30 UTC (rev
75568)
@@ -10,7 +10,11 @@
So far this has only been observed on FreeBSD.
+Adjustment of the bombing message code reveals that the fatal error is
+EPERM - The current thread does not own the mutex.
+
+
The first failure is from a GQA run:
Architecture set to: x86_64--freebsd11.2.
Modified: brlcad/trunk/src/libbu/semaphore.c
===================================================================
--- brlcad/trunk/src/libbu/semaphore.c 2020-04-23 03:34:04 UTC (rev 75567)
+++ brlcad/trunk/src/libbu/semaphore.c 2020-04-23 04:11:30 UTC (rev 75568)
@@ -24,6 +24,7 @@
#include <string.h>
#include <ctype.h>
#include <math.h>
+#include <errno.h>
#include "bio.h"
#include "bu/malloc.h"
@@ -30,7 +31,33 @@
#include "bu/parallel.h"
#include "bu/exit.h"
+static void
+sem_bomb(int eno) {
+ switch (eno) {
+ case EINVAL:
+ bu_bomb("fatal semaphore acquisition failure EINVAL");
+ break;
+ case EBUSY:
+ bu_bomb("fatal semaphore acquisition failure EBUSY");
+ break;
+ case EAGAIN:
+ bu_bomb("fatal semaphore acquisition failure EAGAIN");
+ break;
+ case EDEADLK:
+ bu_bomb("fatal semaphore acquisition failure EDEADLK");
+ break;
+ case EPERM:
+ bu_bomb("fatal semaphore acquisition failure EPERM");
+ break;
+ case EOWNERDEAD:
+ bu_bomb("fatal semaphore acquisition failure EOWNERDEAD");
+ break;
+ default:
+ bu_bomb("fatal semaphore acquisition failure");
+ }
+}
+
/*
* multithreading support for SunOS 5.X / Solaris 2.x
*/
@@ -131,22 +158,25 @@
}
# elif defined(HAVE_PTHREAD_H)
- if (pthread_mutex_lock(&bu_init_lock)) {
+ int ret = pthread_mutex_lock(&bu_init_lock);
+ if (ret) {
fprintf(stderr, "bu_semaphore_acquire(): pthread_mutex_lock() failed on
init lock\n");
- bu_bomb("fatal semaphore acquisition failure");
+ sem_bomb(ret);
}
for (i=bu_nsemaphores; i < nsemaphores; i++) {
memset(&bu_semaphores[i], 0, sizeof(struct bu_semaphores));
bu_semaphores[i].magic = SEMAPHORE_MAGIC;
- if (pthread_mutex_init(&bu_semaphores[i].mu, NULL)) {
+ ret = pthread_mutex_init(&bu_semaphores[i].mu, NULL);
+ if (ret) {
fprintf(stderr, "bu_semaphore_init(): pthread_mutex_init() failed
on [%d] of [%d]\n", i+1, nsemaphores - bu_nsemaphores);
- bu_bomb("fatal semaphore acquisition failure");
+ sem_bomb(ret);
}
}
bu_nsemaphores = nsemaphores;
- if (pthread_mutex_unlock(&bu_init_lock)) {
+ ret = pthread_mutex_unlock(&bu_init_lock);
+ if (ret) {
fprintf(stderr, "bu_semaphore_acquire(): pthread_mutex_unlock() failed
on init lock\n");
- bu_bomb("fatal semaphore acquisition failure");
+ sem_bomb(ret);
}
# elif defined(_WIN32) && !defined(__CYGWIN__)
@@ -229,9 +259,10 @@
# endif
# if defined(HAVE_PTHREAD_H)
- if (pthread_mutex_lock(&bu_semaphores[i].mu)) {
+ int ret = pthread_mutex_lock(&bu_semaphores[i].mu);
+ if (ret) {
fprintf(stderr, "bu_semaphore_acquire(): pthread_mutex_lock() failed on
[%d]\n", i);
- bu_bomb("fatal semaphore acquisition failure");
+ sem_bomb(ret);
}
# endif
@@ -269,9 +300,10 @@
# endif
# if defined(HAVE_PTHREAD_H)
- if (pthread_mutex_unlock(&bu_semaphores[i].mu)) {
+ int ret = pthread_mutex_unlock(&bu_semaphores[i].mu);
+ if (ret) {
fprintf(stderr, "bu_semaphore_acquire(): pthread_mutex_unlock() failed
on [%d]\n", i);
- bu_bomb("fatal semaphore acquisition failure");
+ sem_bomb(ret);
}
# endif
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits