Skip to content
Snippets Groups Projects
Commit 803d0dc6 authored by Utz-Uwe Haus's avatar Utz-Uwe Haus
Browse files

fix too-early-loggin-use crash

parent 3cdf7c9d
Branches
Tags
No related merge requests found
......@@ -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,11 +239,17 @@ 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));
/* 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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment