Hi all,
somehow I have caused an EMT Trap fault.
I am not really sure how I did it, and until now I couldn’t reproduce it.
In general: what is an EMT Trap?
I have built the following structure: a producer fills a shared memory with data and then signals a condvar. The consumer waits for this signal and consumes the data.
After I’ve shut down the producer the consumer fell into this EMT Trap.
The producer does the following when shutting down (signal handler for SIGTERM, SIGABRT, SIGQUIT, SIGSEGV):
[code]void sig_handler (int signo)
{
pthread_mutex_unlock(&ipc.result_ptr->head.mutex);
pthread_mutex_lock(&ipc.status_ptr->head.mutex);
pthread_cond_broadcast(&ipc.status_ptr->head.condvar);
//Set the status to "OFF" and signal the mutex, then remove the SHMem
strncpy(ipc.status_ptr->status, STATE_OFF, sizeof(ipc.status_ptr->status)-1);
pthread_mutex_unlock(&ipc.status_ptr->head.mutex);
if(shm_unlink (CUST_SHM_SERVER_STATUS) != 0)
printf("error on shm_unlink (status): %s", strerror(errno));
if(shm_unlink (CUST_SHM_SERVER_RESULT) != 0)
printf("error on shm_unlink (result): %s", strerror(errno));
exit (0);
}[/code]
The consumer waits on these condvars via
pthread_mutex_lock(&(status_ptr->head.mutex));
pthread_cond_wait(&(status_ptr->head.condvar), &(status_ptr->head.mutex));
When removing a shared memory via shm_unlink, the allocated memory stays untouched, so this shouldn’t be the problem.
Any ideas?
Best regards,
Mr.Green