When a process is down - how to get a coredump in arm board?

Running a multi-threaded program in my arm board one day or more ,The process down .
In order to get a coredump to analysis of the stack , . I use commands ulimited -c unlimited .
but when the process down . no coredump

But I write a test

#include <stdio.h>
int main(void){
    int m = 0;
    scanf("%d",m);
    return 0;
}

input a number , coredump generated .

why?

example:
$ ulimit -c 100
$ cc file.c
$ a.out
43
Segmentation fault (core dumped)

yes I know the test example I wrote can get a coredump .

The question is why my multi-threaded process can't get a coredump when it down or collapsed :wink:

Thanks !

Possible answers

The user running the app has a ulimit setting to prevent it - environment setting
You linked against an object that blocks SIGSEGV/SIGBUS
You block SIGSEGV/SIGBUS in your code somewhere

I do not know much about ARM. When you execute the image file is there some separate environment in which it runs? To check resource settings:
ex:

struct rlimit rlp;
if(getrlimit(RLIMIT_CORE, rlp)==0)
    fprintf(stdout, "core dump blocked\n");

I would guess this is the first place to look, and if this is not the case then it pretty much has to be signal blocking somewhere.

I use " ulimit -c unlimited ", not" ulimit -c 100 "or something else .

I can use functions setjmp, longjmp ,and signal to catch SIGSEGV/SIGBUS and do anything i want .
Even so , I don't know the place generate SIGSEGV/SIGBUS

struct rlimit rlp;
if(getrlimit(RLIMIT_CORE, rlp)==0)
    fprintf(stdout, "core dump blocked\n");

I use ulimit -a to display the setting , It's right !

/proc/sys/fs $ ulimit -a
time(seconds) unlimited
file(blocks) unlimited
data(kbytes) unlimited
stack(kbytes) 2040
coredump(blocks) unlimited
memory(kbytes) unlimited
locked memory(kbytes) 32
process 768
nofiles 1024
vmemory(kbytes) unlimited
locks unlimited
/proc/sys/fs $

Yes, we know, but something in the program or in a library you use may be modifying those limits as well. Doesn't hurt to double-check.

Are you already catching SIGSEGV then?

Perhaps no enough space available on the flash to write the core dump?

:b:

Actually . I test , the collapse has nothing to do with the signal SIGSEGV or whether it has enough space .

I use signal function . but can't catch SIGSEGV when it's down .

I really have no idea!

I don't think that quite translated, try again?

The result of an unhandled signal and the value (name sometimes, too) for each flavor of unix varies. Here is a list, your system may vary

Notice: several signals result in Termin. == termination with no core. Example SIGUSR2. Especially note SIGKILL.
It cannot be blocked. It does not cause a core dump either. This is true for all the UNIX flavors I know about. I believe ARM is a linux port.

Program terminated with signal 13, Broken pipe.
#0 0x4011ceb8 in select () from /lib/libc.so.0
(gdb) bt 6
#0 0x4011ceb8 in select () from /lib/libc.so.0
#1 0x00015298 in NSvrCtrl::GetEvent (this=0x5ff08, timeout=1000)
at nsvrctrl.cpp:187
#2 0x0004ada8 in SKYCAST::NATThreadProc (pParam=0x5feb0) at NatThread.cpp:147
#3 0x40013ac4 in pthread_start_thread () from /lib/libpthread.so.0
#4 0x40013ac4 in pthread_start_thread () from /lib/libpthread.so.0
#5 0x40013ac4 in pthread_start_thread () from /lib/libpthread.so.0
(More stack frames follow...)

Hi Aobai,

There you are: SIGPIPE doesn't generate any core. But you have a pretty good backtrace where the problem lies apparently.

Are you using TCP socket? In this case, you should perhaps blocks SIGPIPE so that you get synchronously informed during the write()/send() (that will return -1 with errno set to EPIPE), instead of getting SIGPIPE.

Cheers,
Lo�c.

Hi Loic,
my process is a multi-threaded ,I use the following code at the beginning of the thread(not the main thread) as you suggested

         struct sigaction act;
          act.sa_handler=SIG_IGN;
          sigemptyset(&act.sa_mask);
          act.sa_flags=0;
          sigaction(SIGPIPE, &act, NULL); 

and run it with the gdb about one day or more . the process don't terminate (before It did). but it stoppedno breakpoint or something else ). which I means use c or r , the process will run again .

if I use bt to see the frame . the result is the same as above .

thanks!

Are you sure your process has been aborted (which should generate a core dump). If somewhere in the process it might be using exit() (this way it won't dump core file).

---------- Post updated at 05:00 PM ---------- Previous update was at 04:57 PM ----------

Sorry for my last post. I was not of 2nd page of the thread.