Results 1 to 7 of 7

Thread: Apache Core Dump File

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2008
    Posts
    3

    Default Apache Core Dump File

    Hi,

    How do I get Apache core dump file? I'm getting many errors that look like:

    [notice] child pid 14217 exit signal Segmentation fault (11)

    but I can't find any core dump files.

    I'm using Debian 4.0 on Webmin VPS 200.

    Thanks!
    --Michi

  2. #2
    Senior Member Power Poster
    Join Date
    Dec 2007
    Posts
    359

    Default

    If the segfault is being caused by a script, try checking the folder in which the script is stored.

    It may also be a good idea to check your Apache error logs and compare the time the segfault occurs with your access logs to determine which script may be the source of the problem.

    I would recommend that you take a look at this thread from the apache-httpd-users mailing list and its follow-up to get started.

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2008
    Posts
    3

    Default Still no cores (with or without Apache)

    Thanks for your reply. It turned out I was hitting some libapache2-mod-python / postgresql SSL related bug (coudn't post the link). I no longer get seg fault from Apache.

    But I still can't get any core files, even without Apache.

    Code:
    $ ulimit
    unlimited
    $ cat test.c
    int main()
    {   
        *(int *)0 = 0;
    }
    $ gcc test.c
    $ ./a.out
    Segmentation fault
    $ ls
    a.out  test.c
    Is there a setting to enable core dumps?
    --Michi

  4. #4
    Senior Member Power Poster
    Join Date
    Dec 2007
    Posts
    359

    Default

    The Apache Debugging Documentation suggests the following:

    To ensure that a core dump is written to a directory which is writable by the user which child processes run as (such as apache), the CoreDumpDirectory directive must be added to httpd.conf; for example:

    CoreDumpDirectory /tmp

  5. #5
    Junior Member Newbie
    Join Date
    Feb 2008
    Posts
    3

    Default

    Yes, I already have that line in apache2.conf (I'm using apache2).

    I'm just curious as to why I can't get any core files with or without apache.

    Thanks!
    --Michi

  6. #6
    Former employee Newbie
    Join Date
    Jul 2006
    Posts
    57

    Default

    Hey,

    You might want to check the status of /proc/sys/fs/suid_dumpable:

    Code:
    cat /proc/sys/fs/suid_dumpable
    it should be set to "2" to get core dumps on any program. You can enter the following as root to change it:

    Code:
    echo 2 > /proc/sys/fs/suid_dumpable
    Additionally, you'll want to make sure that the apache user has the RLIMIT_CORE maximum set above zero, and above the size of the apache process in ram, or else the core dump will be truncated. You can check that by using this C program as apache:


    Code:
    #include <stdio.h>
    #include <sys/resource.h>
    
    static void showvalue(rlim_t lim)
    {
        /*
            All macros may equal RLIM_INFINITY; that test
            must be first; can't use switch statement.
        */
        if (lim == RLIM_INFINITY)
            printf("RLIM_INFINITY");
        else if (lim == RLIM_SAVED_CUR)
            printf("RLIM_SAVED_CUR");
        else if (lim == RLIM_SAVED_MAX)
            printf("RLIM_SAVED_MAX");
        else
            printf("%llu", (unsigned long long)lim);
    }
    
    int showlimit(int resource, const char *name)
    {
        struct rlimit r;
    
        getrlimit(resource, &r);
        printf("%s: ", name);
        printf("rlim_cur = ");
        showvalue(r.rlim_cur);
        printf("; rlim_max = ");
        showvalue(r.rlim_max);
        printf("\n");
        return 0;
    
    }
    
    int main(void)
    {
        struct rlimit r;
        char buf[500] = { 0 };
    
        if (sizeof(rlim_t) > sizeof(long long))
            printf("Warning: rlim_t > long long; results may be wrong\n");
        showlimit(RLIMIT_CORE, "RLIMIT_CORE");
        showlimit(RLIMIT_CPU, "RLIMIT_CPU");
        showlimit(RLIMIT_DATA, "RLIMIT_DATA");
        showlimit(RLIMIT_FSIZE, "RLIMIT_FSIZE");
        showlimit(RLIMIT_NOFILE, "RLIMIT_NOFILE");
        showlimit(RLIMIT_STACK, "RLIMIT_STACK");
        showlimit(RLIMIT_AS, "RLIMIT_AS");
    }
    The reason your c-file was not generating a core dump is likely that that RLIMIT_CORE rlim_cur variable was set to 0 by default. By modifying the program so that the limit was set to the maximum, it is possible to generate a core dump.

    Code:
    maxv@dale:~/blah$ ls
    rlimit  rlimit.c  test  test.c
    maxv@dale:~/blah$ cat test.c 
    #include <stdio.h>
    #include <sys/time.h>
    #include <sys/resource.h>
    #include <errno.h>
    #include <string.h>
    
    
    int main(int argc, char **argv) {   
    
        struct rlimit rlim;
        getrlimit(RLIMIT_CORE, &rlim);
        struct rlimit new_rlim = rlim;
        new_rlim.rlim_cur = new_rlim.rlim_max;
    	
        if (0 == strcmp(argv[1], "coredump")) {
        	setrlimit(RLIMIT_CORE, &new_rlim);
        }
    
        *(int *)0 = 0;
    }
    maxv@dale:~/blah$ gcc test.c -o test
    maxv@dale:~/blah$ ./test coredump
    Segmentation fault (core dumped)
    maxv@dale:~/blah$ ls
    core  rlimit  rlimit.c  test  test.c
    There are some other reasons that it would not generate a core dump as well. You should see "man 5 core" and check all of the reasons there if this does not help you.

  7. #7
    Former employee Newbie
    Join Date
    Jul 2006
    Posts
    57

    Default

    Also check /proc/user_beancounters first for failcounts, as running out of memory is the most common cause of segfaults.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •