Bug 56361 - %e in core_pattern may not be the executable filename if prctl(PR_SET_NAME) has been used.
Summary: %e in core_pattern may not be the executable filename if prctl(PR_SET_NAME) h...
Status: NEW
Alias: None
Product: Other
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: other_other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-08 05:13 UTC by John Steele Scott
Modified: 2013-07-30 05:09 UTC (History)
1 user (show)

See Also:
Kernel Version: 3.8.5
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description John Steele Scott 2013-04-08 05:13:31 UTC
https://www.kernel.org/doc/Documentation/sysctl/kernel.txt shows that %e in /proc/sys/kernel/core_pattern is supposed to expand to the executable filename. However, if prctl() has been used to set a thread name, then %e will expand to that name instead.

┌(toojays@kano)─(600)─(0)─(2013 04 08 14:35:26)
└─(/tmp/exe-name)─> cat /proc/sys/kernel/core_pattern 
core-%e.%p

┌(toojays@kano)─(601)─(0)─(2013 04 08 14:35:51)
└─(/tmp/exe-name)─> cat exe-name.c 
#include <stdlib.h>
#include <sys/prctl.h>

void main (void)
{
  char name[] = "not the exe name";
  prctl(PR_SET_NAME, (unsigned long)&name, 0, 0, 0);
  abort();
}

We would expect that running this program would result in a core file called "core-exe-name.<pid>".

┌(toojays@kano)─(602)─(0)─(2013 04 08 14:36:09)
└─(/tmp/exe-name)─> ./exe-name 
Aborted (core dumped)

However, the core file ends up being named "core-not the exe nam.<pid>".

┌(toojays@kano)─(603)─(134)─(2013 04 08 14:37:04)
└─(/tmp/exe-name)─> ls
core-not the exe nam.4006  exe-name  exe-name.c

Christoph Mathys reported this to lkml a couple of years back, but I found no follow-up, see <https://lkml.org/lkml/2011/11/17/166>.

Note You need to log in before you can comment on or make changes to this bug.