Emmanuel Dreyfus
2014-04-25 16:37:50 UTC
Hi
I would like to obtain a backtrace using libexecinfo in
pthread_key_create() and pthread_key_delete(). I installed libexecinfo
from pkgsrc and added the code below at the end of the two functions.
I use snprintf()/syslog() because pthread__errorfunc() has comments
telling this is the way to go to avoid deadlocks.... but I still deadlock.
Any idea how this should be done?
{
void *bt[BT_DEPTH];
char **btstr;
int depth;
char buf[4096];
size_t len = 0;
int j;
len += snprintf(buf + len, sizeof(buf) - len, "*** %s ***\n",
__func__);
depth = backtrace(bt, BT_DEPTH);
btstr = backtrace_symbols(bt, depth);
for (j = 0; j < depth; j++) {
len += snprintf(buf + len,
sizeof(buf) - len, "#%d %s\n",
j, btstr[j]);
}
syslog(LOG_ERR | LOG_USER, "%s", buf);
}
I would like to obtain a backtrace using libexecinfo in
pthread_key_create() and pthread_key_delete(). I installed libexecinfo
from pkgsrc and added the code below at the end of the two functions.
I use snprintf()/syslog() because pthread__errorfunc() has comments
telling this is the way to go to avoid deadlocks.... but I still deadlock.
Any idea how this should be done?
{
void *bt[BT_DEPTH];
char **btstr;
int depth;
char buf[4096];
size_t len = 0;
int j;
len += snprintf(buf + len, sizeof(buf) - len, "*** %s ***\n",
__func__);
depth = backtrace(bt, BT_DEPTH);
btstr = backtrace_symbols(bt, depth);
for (j = 0; j < depth; j++) {
len += snprintf(buf + len,
sizeof(buf) - len, "#%d %s\n",
j, btstr[j]);
}
syslog(LOG_ERR | LOG_USER, "%s", buf);
}
--
Emmanuel Dreyfus
***@netbsd.org
Emmanuel Dreyfus
***@netbsd.org