Program terminating on receiving - signal SIG34, R

2019-06-22 09:11发布

问题:

In my application the main function calls a funciton - f2 which spawns several threads and application works fine. Now I am trying to add a new function f1 before f2 to spawn a new thread. This new thread prints something on the screen and goes for a sleep in a while loop. I am getting the print once and after some time the application terminates. On debugging the same from GDB I got the following message:

(gdb) Program received signal SIG34, Real-time event 34.Quit
(gdb) bt
#0  0x0fa97cc8 in __nanosleep_nocancel ()
from /export/home/disk4/omsn/401.03022010/montavista/pro/devkit/ppc/82xx/target/lib/tls/libc.so.6
#1  0x0fa97a50 in __sleep (seconds=0) at sleep.c:137
#2  0x10007098 in f2 (arg=0x204) at main.c:152
#3  0x0fd2197c in start_thread (arg=0x204) at pthread_create.c:256
#4  0x0fac853c in clone ()
at ../sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S:100 warning: Previous frame inner to this frame (corrupt stack?)

Code Snippet:

main(){
    f1(); /*New function added to spawn a new task*/
    f2(); /*Existing function spawns several tasks*/
}

Can some one tell me what is "signal SIG34, Real-time event 34" and what could be causing the same.

Here are the details of what f1 does:

int f1(){
    pthread_t thread_id;
    pthread_attr_t attr;
    size_t stack_size;
    int ret=0;

    pthread_attr_init(&attr);
    /*Initialize the stack size*/
    pthread_attr_getstacksize (&attr, &stack_size);
    printf("Default Stack Size = %d\n", stack_size);
    stack_size = 2000;
    pthread_attr_setstacksize (&attr, stack_size);

    /*Initialize detach state*/
    pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);

    printf("Going to spawn thread\n");
    ret = pthread_create(&thread_id, &attr, task_func, NULL);
    if (ret){
        printf("ERROR; return code from pthread_create() is %d\n", ret);
        return ret;
    }else{
        printf("thread successfully spawned, thread id - %d\n", thread_id);
    }

    pthread_attr_destroy(&attr);

    return ret;
}

void* task_func(void* arg){
    printf ("Inside %s going for long sleep\n",__FUNCTION__);
    sleep(100);
    while(1){
        printf ("Inside %s\n",__FUNCTION__);
        sleep(5);
    }

}

回答1:

Linux supports real-time signals as originally defined in the POSIX.1b real-time extensions (and now included in POSIX.1-2001). The range of supported real-time signals is defined by the macros SIGRTMIN and SIGRTMAX. you are getting software interrupt from signal 34.And it's SIGTEMI+0. Type below command in terminal

$ kill -l

You will get list of signals. You will get further information regarding this signal on this link. http://www.freedesktop.org/software/systemd/man/systemd.html I hope this information will help you to find the reason behind getting signal34.Because you have not updated whole code here, so it's little bit hard to say why you are getting this SIGNAL34.



回答2:

To fix this problem, create a .gdbinit file, with the following content:

handle SIG34 nostop noprint pass noignore