Bug 10528 - Core dump is not created if /proc/sys/kernel/core_pattern is configure to store the dump at /
Summary: Core dump is not created if /proc/sys/kernel/core_pattern is configure to sto...
Alias: None
Product: Samba 4.0
Classification: Unclassified
Component: Other (show other bugs)
Version: 4.0.14
Hardware: All Linux
: P5 normal (vote)
Target Milestone: ---
Assignee: Jeremy Allison
QA Contact: Samba QA Contact
Depends on:
Reported: 2014-03-30 11:02 UTC by Lev
Modified: 2014-04-18 20:31 UTC (History)
2 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Lev 2014-03-30 11:02:12 UTC
If /proc/sys/kernel/core_pattern is configured to store the core dump at root (e.g. it is set to "/core"), get_linux_corepath() just returns what it read in core_pattern. As a result corepath becomes full path to the core dump, and not path to the directory containing the core.
Later, on any panic, dump_core() tries to chdir(corepath) and fails (directory /core doesn't exist). As a result core dump is not created at all.

Proposed fix:

diff --git a/samba/samba-4.0.14/source3/lib/dumpcore.c b/samba/samba-4.0.14/source3/lib/dumpcore.c
index 90acc16..93c2e58 100644
--- a/samba/samba-4.0.14/source3/lib/dumpcore.c
+++ b/samba/samba-4.0.14/source3/lib/dumpcore.c
@@ -175,10 +175,11 @@ static char *get_linux_corepath(void)
        end = strrchr_m(result, '/');
-       if ((end != result) /* this would be the only / */
-           && (end != NULL)) {
+       if (end != result)
                *end = '\0';
-       }
+       else
+               result = "/";
        return result;

I think check (end!=NULL) is also not required, at this stage we know result[0] == '/', so strrchr_m(result, '/') can't return NULL.
Comment 1 Jeremy Allison 2014-04-10 00:06:27 UTC
I'll take a look at this.