Calling backtrace_symbols_fd from signal handler fails
[FONT="Arial"][SIZE="2"]
I have a multi-threaded application which sets up a signal handler in thread 1. The signal handler consists of
void Signal_Handler(int signum, siginfo_t *sinfo, void *ucontxt) {
void *backtrace_buffer[100];
size_t backtrace_size;
/*----------------------------------------------------------------------------------*
! Determine if a backtrace exists (backtrace_size > 0). !
*----------------------------------------------------------------------------------*/
backtrace_size = backtrace(backtrace_buffer, 100);
int backtrace_hdl = open("/et3mach/configmgr_backtrace",O_APPEND,S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
chmod("/et3mach/configmgr_backtrace",S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
backtrace_symbols_fd(backtrace_buffer,backtrace_size,backtrace_hdl);
close(backtrace_hdl);
The backtrace call works fine; it returns a count of 11. The open works file and returns a valid file handle. The call to backtrace_symbols_fd results in the program terminating. Nothing is written to the file and the next instruction is not run.
Can anyone suggest what might be going on? According to my research both backtrace calls do no memory allocation and are valid in a signal handler.
I also tried backtrace_symbols with the same results.
I'm running RHEL5.0-2010-x86_64 with a 2.6.18-194.el5 kernel. compile used was gcc 4.1.2.
Last edited by kenkahn; 11-12-2012 at 11:51 AM.
|