segmentation fault without (core dumped)

Viewed 263

I'm running a fortran program on ubuntu 18.04, and got a segmentation fault but no core generated. I've already tried the previous suggestion as below:

echo "1" > /proc/sys/kernel/core_uses_pid
echo "core" > /proc/sys/kernel/core_pattern
ulimit -c unlimited

here is the result:

root@goodluck:# ulimit -a
core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 15415
max locked memory       (kbytes, -l) 65536
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 15415
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
root@goodluck:# gdb LPDM_gnu_omp 
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
(gdb) run
Starting program: /home/yufei/LPDM/work/democode/LPDM_gnu_omp 
During startup program terminated with signal SIGSEGV, Segmentation fault.

but the core file still not generated, and when I got the segmentation fault, I didn't get this

segmentation fault(core dumped)

instead I got this:

segmentation fault

Could someone help me? I searched all the internet but got no clues. Thanks a lot!

1 Answers

There are a few possible reasons a core may not be generated:

  1. The directory into which the core would have been generated is not writable, or on a read-only filesystem, or on a full filesystem.
  2. The program disabled core generation by calling setrlimit(RLIMIT_CORE, {0, 0}) (undoing ulimit -c unlimited), or calling prctl(PR_SET_DUMPABLE, 0) description.

There might be other reasons as well. I suggest verifying that /tmp is not full, and trying to dump a core there.

If that still doesn't work, probably ulimit(2), prlimit64 or prctl(2) is to blame. Run the program under strace -e ulimit,prlimit64,prctl to confirm.

If you are just looking for "why is the program crashing", you don't (usually) need a core -- you could run the program directly under debugger, e.g.

gdb LPDM_gnu_omp
(gdb) run
... what for crash, GDB will stop
(gdb) where

Update:

What does it mean for a Fortran program to "call ulimit(RLIMIT_CORE, {0, 0})"
If I gave my Fortran compiler the "program" call ulimit(RLIMIT_CORE, {0, 0}); end I'd be surprised to get something back that I can run

You are asking about the mechanics of invoking a C function from Fortran, while my answer is about the conceptual reason why you may be left without a core.

For mechanics, you would need to look at your Fortran implementation documentation, e.g. GCC Fortran<->C interface is defined here.

P.S. the ulimit(RLIMIT_CORE, {0, 0}) is not a valid C either, it's a shorthand for:

  struct rlimit r;
  r.rlim_min = r.rlim_max = 0;
  setrlimit(RLIMIT_CORE, &r);

P.P.S. I mis-remembered the ulimit(3) interface -- I meant setrlimit(2) everywhere I used ulimit above. I fixed the uses.

Related