get the core file in perl script with backtick - linux

On my ubuntu 14.04 (Linux 3.19.0 64bit) PC, I ran a perl program that has the following in a loop
$params = setupParams();
$ret = `SOME_CMD $params`;
...
But for some reason, SOME_CMD sometimes gaves Segmentation fault (core dumped) occasionally. In order to figure out the cause of the core dump, I need to get the core file.
Unfortunately I tried ulimit -S -c 0 on the terminal where I ran the perl script, but it didn't produce a core file.
Any ideas would be appreciated.

ulimit -c 0 prevents core files to be written. You need to use
ulimit -c unlimited
Btw: you should upgrade to a maintained OS.

Related

Why kill command does not generate core while gcore can?

I can use gcore generating the core file of my application which was built with debug symbol. Out of curiosity, I tried using kill command to generated the core file, but no core is generated.
Here are the steps I took:
I first ran the following commands:
ulimit -c unlimited
sudo sysctl -w kernel.core_pattern=/tmp/core-%e.%p.%h.%t
Then start the application.
Then I tried the SIGABRT, SIGTRAP, SIGQUIT, there is no core file generated:
kill -SIGABRT `pidof my_app`
kill -SIGTRAP `pidof my_app`
kill -SIGQUIT `pidof my_app`
In all these runs, my_app was stoped, but there is no core file, locally or /tmp.
I am using Ubuntu 20.04.
Do you see anything wrong?

Linux perf tool run issues

I am using perf tool to bench mark one of my projects. The issue I am facing is that wo get automatihen I run perf tool on my machine, everything works fine.
However, I am trying to run perf in automation servers to make it part of my check in process but I am getting the following error from automation servers
WARNING: Kernel address maps (/proc/{kallsyms,modules}) are restricted,
check /proc/sys/kernel/kptr_restrict.
Samples in kernel functions may not be resolved if a suitable vmlinux
file is not found in the buildid cache or in the vmlinux path.
Samples in kernel modules won't be resolved at all.
If some relocation was applied (e.g. kexec) symbols may be misresolved
even with a suitable vmlinux or kallsyms file.
Error:
Permission error - are you root?
Consider tweaking /proc/sys/kernel/perf_event_paranoid:
-1 - Not paranoid at all
0 - Disallow raw tracepoint access for unpriv
1 - Disallow cpu events for unpriv
2 - Disallow kernel profiling for unpriv
fp: Terminated
I tried changing /proc/sys/kernel/perf_event_paranoid to -1 and 0 but still see the same issue.
Anybody seen this before? Why would I need to run the command as root? I am able to run it on my machine without sudo.
by the way, the command is like this:
perf record -m 32 -F 99 -p xxxx -a -g --call-graph fp
You can't use -a (full system profiling) and sample kernel from non-root user: http://man7.org/linux/man-pages/man1/perf-record.1.html
Try running it without -a option and with event limited to userspace events by :u suffix:
perf record -m 32 -F 99 -p $PID -g --call-graph fp -e cycles:u
Or use software event for virtualized platforms without PMU passthrough
perf record -m 32 -F 99 -p $PID -g --call-graph fp -e cpu-clock:u

ulimit -s on Netbeans 8.0.2

I want to run a C program in NetBeans 8.0.2 (on Xubuntu 14.04) with ulimit -s set. I've already tried on Re-run with arguments writing ulimit -s 2048; "${OUTPUT_PATH}", but it shows me this error:
/bin/sh: 1: exec: ulimit: not found
I don't want to compile the program on my own in order to set ulimit on the terminal.
This doesn't look like a C question.
Anyway, on Linux, ulimitis not a system command, it's a bash builtin. Unless /bin/sh is linked to bash (which it is usually not) the command won't be known to the shell.
try /bin/bash -c ulimit -s 2048 instead.
Note that this new limit will only be active in this particular shell - once you return from it, you'll see whatever you had before.

crashed process but no core dump file

I have tried may things but I can get my program to generate core dump when it crashes.
$ ulimit -c
200000000
The limit seems ok.
$ cat /proc/sys/fs/suid_dumpable
2
The pattern looks ok.
$ cat /proc/sys/kernel/core_pattern
/tmp/core_%e
When I kill -SIGSEGV I get a core dump. The process has very little memory. Why is there no core dump file?
I have a print at the end of main that i don't see and I'm running the program in bash while loop with sleep 2;
The os is Ubuntu 12.04LTS

How do do configure a Hudson linux slave to generate core files?

I've seeing occasional segmentation faults in glibc on several different Fedora Core 9 Hudson Slaves. I've attempted to configure each slave to generate core files and place them in /corefiles, but have had no luck.
Here is what I've done on each linux slave:
1) Create a corefile storage location
sudo install -m 1777 -d /corefiles
2) Directed the corefiles to the storage location by adding the following to /etc/sysctl.conf
kernel.core_pattern = /corefiles/core.%e-PID:%p-%t-signal_%s-%h
3) Enabled unlimited corefiles for all users by adding the following to /etc/profile
ulimit -c unlimited
Is there some additional Linux magic required or do I need to do something to the Hudson slave or JVM?
Thanks for the help
Did you reboot or run "sysctl -p" (as root) after editing /etc/sysctl.conf ?
Also, if i remember correctly, ulimit values are per user and calling ulimit wont survive a boot. You should add this to /etc/security/limits.conf:
* soft core unlimited
Or call ulimit in the script that starts hudson if you don't wont everyone to produce coredumps.
I figured this out :-).
The issue is Hudson invokes the bash shell as a non-interactive shell, which will bypass the ulimit setting in /etc/profile. The solution is to add the BASH_ENV environmental variable tothe Hudson slaves and set the value to a file with ulimit -c unlimited set.

Resources