user2690527
user2690527

Reputation: 1881

How to selectively disable logging of core dumps for a particular executable?

On my server I collect information about core dumps with systemd as I normally want to know about core dumps. The relevant settings are

server ~ # cat /proc/sys/kernel/core_pattern
|/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h

server ~ # ulimit -c
unlimited

server ~ # cat /etc/systemd/coredump.conf 
[Coredump]
#Storage=external
#Compress=yes
# On 32-bit, the default is 1G instead of 32G.
#ProcessSizeMax=32G
#ExternalSizeMax=32G
#JournalSizeMax=767M
#MaxUse=
#KeepFree=

However, the configuration script of couple of packages compile and execute a small test program conftest which is expected to core dump on purpose. (More details below, in case you are interested.) This results in some undesired entries with critical severity in the system logs. Normally, core dumps are are critical thing, expect in this case they are not.

How can I filter out those "false" error logs from entering the system log at all? Also the stored core dumps are piling up in /var/lib/systemd/coredump/ for no reason.

As the executable is always conftest something like "if %e equals conftest pipe it to /dev/null otherwise to /usr/lib/systemd/systemd-coredump" should do it.


The relevant lines in the logs of the ./configure scripts are

configure:12918: checking whether printf supports the 'n' directive
configure:12992: x86_64-pc-linux-gnu-gcc -o conftest -O2 -pipe -march=native  -Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs conftest.c  >&5
configure:12992: $? = 0
configure:12992: ./conftest
*** %n in writable segment detected ***
./configure: line 3126:  1354 Aborted                 (core dumped) ./conftest$ac_exeext
configure:12992: $? = 134
configure: program exited with status 134
configure: failed program was:
| /* confdefs.h */
| /* ... */
| static char fmtstring[10];
| static char buf[100];
| int main ()
| {
|   int count = -1;
| #ifdef _MSC_VER
|   _set_invalid_parameter_handler (invalid_parameter_handler);
| #endif
|   /* Copy the format string.  Some systems (glibc with _FORTIFY_SOURCE=2)
|      support %n in format strings in read-only memory but not in writable
|      memory.  */
|   strcpy (fmtstring, "%d %n");
|   if (sprintf (buf, fmtstring, 123, &count, 33, 44, 55) < 0
|       || strcmp (buf, "123 ") != 0
|       || count != 4)
|     return 1;
|   return 0;
| }
configure:13007: result: no

The script ./configure intentionally compiles a program conftest which uses an illegal format character inside strcpy and the executable is expected to core dump. The ./configure script

Upvotes: 1

Views: 164

Answers (0)

Related Questions