develooper Front page | perl.perl6.users | Postings from September 2019

Re: core dump

Thread Previous
From:
ToddAndMargo via perl6-users
Date:
September 3, 2019 21:49
Subject:
Re: core dump
Message ID:
4b52e7b9-bc71-08b5-fecf-dbbc43c2f872@zoho.com
>> *From:* ToddAndMargo via perl6-users <perl6-users@perl.org>
>> *Sent:* Friday, August 30, 2019 7:21 PM
>> *To:* perl6-users@perl.org <perl6-users@perl.org>
>> *Subject:* Re: core dump
>> On 8/9/19 3:41 PM, ToddAndMargo via perl6-users wrote:
>>> Hi All,
>>> 
>>> Fedora 30
>>> rakudo-0.2019.03-2.fc30.x86_64
>>> 
>>> I have a weird question.  I need to simulate a core
>>> dump under a bash (ulimit) shell.
>>> 
>>> Any of you guys know who to get Perl to crash with a
>>> core dump?
>>> 
>>> I need to prove that core dumps are not
>>> active on my system.  Or if I am mistaken.
>>> 
>>> 
>>> Many thanks,
>>> -T
>>> 
>> 
>> Follow up:
>> 
>>        To trigger a core dump:
>>            $ kill -s SIGSEGV PID     Subsitute your PID
>>            $ kill -s SIGSEGV $$      Will kill your current shell
>> 
>> 
>> Since core dumps have changed significantly under Fedora 30
>> (systemd), anyone wants my full notes, please ping me
>> on the subject line and respond on this thread.
>> 
>> -T


On 9/3/19 9:08 AM, Andy Bach wrote:
> On my box, man core shows how to dump core using ctrl-backslash
> $ perl
> ^\Quit (core dumped)
> 
> It also gives the example of creating a pipeline for core handling (.c 
> file text below):
>          $ cc -o core_pattern_pipe_test core_pattern_pipe_test.c
>             $ su
>             Password:
>             # echo "|$PWD/core_pattern_pipe_test %p UID=%u GID=%g 
> sig=%s" > \
>                 /proc/sys/kernel/core_pattern
>             # exit
>             $ sleep 100
>             ^\                     # type control-backslash
>             Quit (core dumped)
>             $ cat core.info
>             argc=5
>             argc[0]=</home/mtk/core_pattern_pipe_test>
>             argc[1]=<20575>
>             argc[2]=<UID=1000>
>             argc[3]=<GID=100>
>             argc[4]=<sig=3>
>             Total bytes in core dump: 282624
> 
> I used just
> $ perl
> ^\Quit (core dumped)
> $ cat core.info
> argc=5
> argc[0]=</usr/local/bin/core_pipe_test>
> argc[1]=<3804>
> argc[2]=<UID=1000>
> argc[3]=<GID=1000>
> argc[4]=<sig=3>
> Total bytes in core dump: 602112
> 
> 
>    /* core_pattern_pipe_test.c */
> 
>         #define _GNU_SOURCE
>         #include <sys/stat.h>
>         #include <fcntl.h>
>         #include <limits.h>
>         #include <stdio.h>
>         #include <stdlib.h>
>         #include <unistd.h>
> 
>         #define BUF_SIZE 1024
> 
>         int
>         main(int argc, char *argv[])
>         {
>             int tot, j;
>             ssize_t nread;
>             char buf[BUF_SIZE];
>             FILE *fp;
>             char cwd[PATH_MAX];
> 
>             /* Change our current working directory to that of the
>                crashing process */
> 
>             snprintf(cwd, PATH_MAX, "/proc/%s/cwd", argv[1]);
>             chdir(cwd);
> 
>             /* Write output to file "core.info" in that directory */
> 
>             fp = fopen("core.info", "w+");
>             if (fp == NULL)
>                 exit(EXIT_FAILURE);
> 
>             /* Display command-line arguments given to core_pattern
>                pipe program */
> 
>             fprintf(fp, "argc=%d\n", argc);
>             for (j = 0; j < argc; j++)
>                 fprintf(fp, "argc[%d]=<%s>\n", j, argv[j]);
> 
>             /* Count bytes in standard input (the core dump) */
> 
>             tot = 0;
>             while ((nread = read(STDIN_FILENO, buf, BUF_SIZE)) > 0)
>                 tot += nread;
>             fprintf(fp, "Total bytes in core dump: %d\n", tot);
> 
>             fclose(fp);
>             exit(EXIT_SUCCESS);
>         }
> 


Are you using system5 or systemd?

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About