diff --git a/maestro/logging.c b/maestro/logging.c index b99cb24a9ed88fa21f69465560c5680b0a1174b6..8ed767b5cadd5d1b76c3d4c5be4291ef331cbc25 100644 --- a/maestro/logging.c +++ b/maestro/logging.c @@ -208,7 +208,8 @@ mstro__ensure_threadid(void) /* valgrind users: this will leak. Sorry :) (we could use C11 _Tread_local instead, but need to check all compilers we care about do it well) */ char *tmp = malloc(16+2); if(tmp==NULL) { - ERR("Failed to allocate thread-identifier\n"); + /* cannot use our logging infrastructure yet, so use stderr */ + fprintf(stderr, "Failed to allocate thread-identifier\n"); abort(); } @@ -238,9 +239,15 @@ mstro__ensure_threadid(void) int s = pthread_setspecific(g_thread_descriptor_key, tid); if(s!=0) { - ERR("Failed to set thread identifier: %d (%s)\n", - errno, strerror(errno)); - abort(); + /* cannot use our logging infrastructure yet, so use stderr */ + if(s==EINVAL) { + fprintf(stderr, "Failed to set thread identifier; likely mstro_init has not been called, proceeding with caution\n"); + tid=0; + } else { + fprintf(stderr, "Failed to set thread identifier: %d (%s) (errno %d = %s)\n", + s, strerror(s), errno, strerror(errno)); + abort(); + } } } return tid;