.\" -*- coding: UTF-8 -*- .\" Copyright (c) 2006, 2008 by Michael Kerrisk .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH CORE 5 "1 listopada 2020 r." Linux "Podręcznik programisty Linuksa" .SH NAZWA core \- plik zrzutu pamięci .SH OPIS The default action of certain signals is to cause a process to terminate and produce a \fIcore dump file\fP, a file containing an image of the process's memory at the time of termination. This image can be used in a debugger (e.g., \fBgdb\fP(1)) to inspect the state of the program at the time that it terminated. A list of the signals which cause a process to dump core can be found in \fBsignal\fP(7). .PP Proces może ustawić miękki limit zasobów \fBRLIMIT_CORE\fP, aby ograniczyć maksymalny rozmiar pliku, który zostanie utworzony po otrzymaniu sygnału powodującego zrzut pamięci; szczegółowe informacje można znaleźć w \fBgetrlimit\fP(2). .PP W następujących wypadkach plik zrzutu pamięci nie będzie utworzony: .IP * 3 The process does not have permission to write the core file. (By default, the core file is called \fIcore\fP or \fIcore.pid\fP, where \fIpid\fP is the ID of the process that dumped core, and is created in the current working directory. See below for details on naming.) Writing the core file fails if the directory in which it is to be created is not writable, or if a file with the same name exists and is not writable or is not a regular file (e.g., it is a directory or a symbolic link). .IP * Już istnieje (zapisywalny, zwykły) plik o tej samej nazwie, jaka zostałaby użyta dla pliku zrzutu pamięci, jednakże plik ten ma więcej niż jedno dowiązanie twarde. .IP * System plików, w którym zostałby utworzony plik zrzutu pamięci, jest pełny, wyczerpał mu się limit i\-węzłów, jest zamontowany w trybie tylko do odczytu albo użytkownik osiągnął kwotę systemu plików .IP * Nie istnieje katalog, w którym miałby być utworzony plik zrzutu pamięci. .IP * Limity zasobów \fBRLIMIT_CORE\fP (rozmiar pliku zrzutu pamięci) lub \fBRLIMIT_FSIZE\fP (rozmiar pliku) dla procesu są ustawione na zero; patrz \fBgetrlimit\fP(2) i dokumentacja wbudowanego w powłokę polecenia \fIulimit\fP (lub \fIlimit\fP w powłoce \fIcsh\fP(1)). .IP * The binary being executed by the process does not have read permission enabled. (This is a security measure to ensure that an executable whose contents are not readable does not produce a\(empossibly readable\(emcore dump containing an image of the executable.) .IP * .\" FIXME . Perhaps relocate discussion of /proc/sys/fs/suid_dumpable .\" and PR_SET_DUMPABLE to this page? Proces uruchomił program z flagą set\-user\-ID (set\-group\-ID), którego właścicielem jest użytkownik (grupa) inny niż rzeczywisty użytkownik (grupa) procesu lub proces wykonujący program ma przywileje plikowe (zob. \fBcapabilities\fP(7)). (Jednakże patrz w \fBprctl\fP(2) opis operacji \fBPR_SET_DUMPABLE\fP oraz w \fBproc\fP(5) opis pliku \fI/proc/sys/fs/suid_dumpable\fP). .IP * \fI/proc/sys/kernel/core_pattern\fP is empty and \fI/proc/sys/kernel/core_uses_pid\fP contains the value 0. (These files are described below.) Note that if \fI/proc/sys/kernel/core_pattern\fP is empty and \fI/proc/sys/kernel/core_uses_pid\fP contains the value 1, core dump files will have names of the form \fI.pid\fP, and such files are hidden unless one uses the \fBls\fP(1) \fI\-a\fP option. .IP * .\" commit 046d662f481830e652ac34cd112249adde16452a (od Linuksa 3.7) Jądro zostało zbudowane bez opcji \fBCONFIG_COREDUMP\fP. .PP Dodatkowo zrzut pamięci może nie zawierać części przestrzeni adresowej procesu jeśli użyto flagi \fBMADV_DONTDUMP\fP \fBmadvise\fP(2). .PP .\" On systems that employ \fBsystemd\fP(1) as the \fIinit\fP framework, core dumps may instead be placed in a location determined by \fBsystemd\fP(1). See below for further details. .SS "Nazwy plików zrzutu pamięci" Domyślnie plik zrzutu pamięci nazywa się \fIcore\fP, jednakże w pliku \fI/proc/sys/kernel/core_pattern\fP (od wersji 2.6 i 2.4.21 Linuksa) można zdefiniować szablon, który będzie użyty do nazywania plików zrzutu pamięci. Szablon ten może zawierać specjalne znaczniki zaczynające się od "%", które podczas tworzenia pliku zrzutu będą zastąpione następującymi wartościami: .PP .RS 4 .PD 0 .TP 4 %% Pojedynczy znak %. .TP %c Miękki limit zasobu rozmiaru pliku zrzutu pamięci procesu zrzucającego pamięć (od Linuksa 2.6.24). .TP %d .\" Added in git commit 12a2b4b2241e318b4f6df31228e4272d2c2968a1 Tryb zrzutu\(emtaki sam jak wartość zwracana przez \fBprctl\fP(2) \fBPR_GET_DUMPABLE\fP (od Linuksa 3.7). .TP \fB%e\fP The process or thread's \fIcomm\fP value, which typically is the same as the executable filename (without path prefix, and truncated to a maximum of 15 characters), but may have been modified to be something different; see the discussion of \fI/proc/[pid]/comm\fP and \fI/proc/[pid]/task/[tid]/comm\fP in \fBproc\fP(5). .TP \fB%E\fP Nazwa ścieżki pliku wykonywalnego, z ukośnikami ("/") zastąpionymi przez wykrzykniki ("!") (od Linuksa 3.0). .TP %g Numeryczny identyfikator grupy (GID) procesu, który zrzucił pamięć. .TP %h Nazwa komputera (taka sama jak \fInodename\fP zwracane przez \fBuname\fP(2)). .TP %i .\" commit b03023ecbdb76c1dec86b41ed80b123c22783220 identyfikator wątku (TID) który zainicjował zrzut pamięci, taki jak w przestrzeni nazw PID\-ów w której wątek działa (od Linuksa 3.18). .TP \fB%I\fP .\" commit b03023ecbdb76c1dec86b41ed80b123c22783220 identyfikator wątku (TID) który zainicjował zrzut pamięci, taki jak w początkowej przestrzeni nazw PID\-ów (od Linuksa 3.18). .TP %p identyfikator zrzucanego procesu, taki jak w przestrzeni nazw PID\-ów w której proces działa. .TP %P .\" Added in git commit 65aafb1e7484b7434a0c1d4c593191ebe5776a2f identyfikator zrzucanego procesu, taki jak w początkowej przestrzeni nazw PID\-ów (od Linuksa 3.12). .TP %s Numer sygnału powodującego zrzut pamięci. .TP %t Czas zrzutu wyrażony w sekundach od początku epoki, czyli od 1970\-01\-01 00:00:00 +0000 (UTC). .TP %u Numeryczny identyfikator użytkownika (UID) procesu, który zrzucił pamięć. .PD .RE .PP Jeśli szablon kończy się pojedynczym znakiem %, to znak ten zostanie usunięty z nazwy pliku zrzutu. Podobnie zostaną usunięte wszelkie kombinacje % ze znakami innymi niż te, wymienione powyżej. Wszystkie inne znaki szablonu staną się częścią nazwy pliku zrzutu. Szablon może zawierać znaki "/", które są interpretowane jako separatory nazw katalogów. Maksymalna długość wygenerowanej nazwy pliku wynosi 128 bajtów (64 bajty w wersjach jądra wcześniejszych niż 2.6.19). Domyślną wartością jest "core". W celu zachowania wstecznej zgodności, jeśli \fI/proc/sys/kernel/core_pattern\fP nie zawiera \fI%p\fP, a \fI/proc/sys/kernel/core_uses_pid\fP (patrz niżej) ma niezerową wartość, to .PID będzie dołączony do nazwy pliku zrzutu. .PP Paths are interpreted according to the settings that are active for the crashing process. That means the crashing process's mount namespace (see \fBmount_namespaces\fP(7)), its current working directory (found via \fBgetcwd\fP(2)), and its root directory (see \fBchroot\fP(2)). .PP Od wersji 2.4 Linux dostarcza również bardziej prymitywnej metody kontrolowania nazwy pliku zrzutu pamięci. Gdy plik \fI/proc/sys/kernel/core_uses_pid\fP zawiera wartość 0, plik zrzutu pamięci ma po prostu nazwę \fIcore\fP. Gdy plik ten zawiera wartość niezerową, plik zrzutu pamięci będzie zawierał w swojej nazwie ID procesu, w postaci \fIcore.PID\fP. .PP .\" 9520628e8ceb69fa9a4aee6b57f22675d9e1b709 Od Linuksa 3.6 jeśli \fI/proc/sys/fs/suid_dumpable\fP ustawiono na 2 ("suidsafe") to wzorzec musi być albo ścieżką absolutną (zaczynającą się znakiem "/") lub potokiem, zgodnie z poniższą definicją. .SS "Przekazywanie zrzutów pamięci potokiem do programu" Since kernel 2.6.19, Linux supports an alternate syntax for the \fI/proc/sys/kernel/core_pattern\fP file. If the first character of this file is a pipe symbol (\fB|\fP), then the remainder of the line is interpreted as the command\-line for a user\-space program (or script) that is to be executed. .PP .\" commit 315c69261dd3fa12dbc830d4fa00d1fad98d3b03 Since kernel 5.3.0, the pipe template is split on spaces into an argument list \fIbefore\fP the template parameters are expanded. In earlier kernels, the template parameters are expanded first and the resulting string is split on spaces into an argument list. This means that in earlier kernels executable names added by the \fI%e\fP and \fI%E\fP template parameters could get split into multiple arguments. So the core dump handler needs to put the executable names as the last argument and ensure it joins all parts of the executable name using spaces. Executable names with multiple spaces in them are not correctly represented in earlier kernels, meaning that the core dump handler needs to use mechanisms to find the executable name. .PP Instead of being written to a file, the core dump is given as standard input to the program. Note the following points: .IP * 3 Program musi być podany używając ścieżki bezwzględnej (lub ścieżki względnej w stosunku do korzenia systemu plików, czyli katalogu \fI/\fP) i musi występować bezpośrednio po znaku "|". .IP * Argumenty linii poleceń mogą zawierać dowolne z wymienionych powyżej specyfikatorów %. Na przykład, aby przekazać identyfikator procesu zrzucającego pamięć, należy podać \fI%p\fP jako argument. .IP * Proces tworzony do wykonania programu jest wykonywany jako użytkownik i grupa \fIroot\fP. .IP * Running as \fIroot\fP does not confer any exceptional security bypasses. Namely, LSMs (e.g., SELinux) are still active and may prevent the handler from accessing details about the crashed process via \fI/proc/[pid]\fP. .IP * The program pathname is interpreted with respect to the initial mount namespace as it is always executed there. It is not affected by the settings (e.g., root directory, mount namespace, current working directory) of the crashing process. .IP * The process runs in the initial namespaces (PID, mount, user, and so on) and not in the namespaces of the crashing process. One can utilize specifiers such as \fI%P\fP to find the right \fI/proc/[pid]\fP directory and probe/enter the crashing process's namespaces if needed. .IP * The process starts with its current working directory as the root directory. If desired, it is possible change to the working directory of the dumping process by employing the value provided by the \fI%P\fP specifier to change to the location of the dumping process via \fI/proc/[pid]/cwd\fP. .IP * Można przekazać do programu argumenty linii poleceń (od Linuksa 2.6.24), rozdzielając je spacjami (aż do wyczerpania limitu całkowitej długości linii wynoszącego 128 bajtów). .IP * .\" The \fBRLIMIT_CORE\fP limit is not enforced for core dumps that are piped to a program via this mechanism. .SS /proc/sys/kernel/core_pipe_limit When collecting core dumps via a pipe to a user\-space program, it can be useful for the collecting program to gather data about the crashing process from that process's \fI/proc/[pid]\fP directory. In order to do this safely, the kernel must wait for the program collecting the core dump to exit, so as not to remove the crashing process's \fI/proc/[pid]\fP files prematurely. This in turn creates the possibility that a misbehaving collecting program can block the reaping of a crashed process by simply never exiting. .PP .\" commit a293980c2e261bd5b0d2a77340dd04f684caff58 Since Linux 2.6.32, the \fI/proc/sys/kernel/core_pipe_limit\fP can be used to defend against this possibility. The value in this file defines how many concurrent crashing processes may be piped to user\-space programs in parallel. If this value is exceeded, then those crashing processes above this value are noted in the kernel log and their core dumps are skipped. .PP .\" A value of 0 in this file is special. It indicates that unlimited processes may be captured in parallel, but that no waiting will take place (i.e., the collecting program is not guaranteed access to \fI/proc/\fP). The default value for this file is 0. .SS "Kontrolowanie mapowań zapisywanych do pliku zrzutu pamięci" Od wersji 2.6.23 jądra można użyć specyficznego dla Linuksa pliku \fI/proc/[PID]/coredump_filter\fP do kontrolowania, które segmenty pamięci zostaną zapisane do pliku zrzutu pamięci, w przypadku gdy pamięć jest zrzucana przez proces o podanym identyfikatorze. .PP Wartość w tym pliku jest maską bitową typów mapowań pamięci (patrz \fBmmap\fP(2)). Jeśli bit jest ustawiony w masce, to odpowiadające mu mapowanie jest zapisywane w pliku, w przeciwnym wypadku \- nie jest. Bity w masce mają następujące znaczenia: .PP .PD 0 .RS 4 .TP bit 0 Zrzucanie anonimowych mapowań prywatnych. .TP bit 1 Zrzucanie anonimowych mapowań współdzielonych. .TP bit 2 Zrzucanie prywatnych mapowań plików. .TP bit 3 .\" file-backed shared mappings of course also update the underlying .\" mapped file. Zrzucanie współdzielonych mapowań plików. .TP bit 4 (od Linuksa 2.6.24) Zrzucanie nagłówków ELF. .TP bit 5 (od Linuksa 2.6.28) Zrzucanie prywatnych dużych stron. .TP bit 6 (od Linuksa 2.6.28) Zrzucanie współdzielonych dużych stron. .TP bit 7 (od Linuksa 4.4) .\" commit ab27a8d04b32b6ee8c30c14c4afd1058e8addc82 Zrzucanie prywatnych stron DAX. .TP bit 8 (od Linuksa 4.4) .\" commit ab27a8d04b32b6ee8c30c14c4afd1058e8addc82 Zrzucanie współdzielonych stron DAX. .RE .PD .PP Domyślnie ustawione są następujące bity: 0, 1, 4 (jeśli jest włączona opcja \fBCONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS\fP konfiguracji jądra) oraz 5. Tę wartość domyślną można zmodyfikować przy rozruchu za pomocą opcji \fIcoredump_filter\fP. .PP Wartość tego pliku jest wyświetlana szesnastkowo (z tego powodu domyślna wartość jest wyświetlana jako 33). .PP Strony wejścia/wyjścia mapowane w pamięci, takie jak frame buffer, nigdy nie są zrzucane, a wirtualne strony DSO (\fBvdso\fP(7)) są zawsze zrzucane, niezależnie od wartości \fIcoredump_filter\fP. .PP Proces\-dziecko utworzony przez \fBfork\fP(2) dziedziczy wartość \fIcoredump_filter\fP od swojego rodzica; wartość ta jest także zachowywana podczas \fBexecve\fP(2). .PP Może być użyteczne ustawienie \fIcoredump_filter\fP w powłoce przed uruchomieniem programu, na przykład: .PP .in +4n .EX $\fB echo 0x7 > /proc/self/coredump_filter\fP $\fB ./some_program\fP .EE .in .PP .\" Plik istnieje, jeśli jądro zostało zbudowane z włączoną opcją konfiguracji \fBCONFIG_ELF_CORE\fP. .SS "Core dumps and systemd" On systems using the \fBsystemd\fP(1) \fIinit\fP framework, core dumps may be placed in a location determined by \fBsystemd\fP(1). To do this, \fBsystemd\fP(1) employs the \fIcore_pattern\fP feature that allows piping core dumps to a program. One can verify this by checking whether core dumps are being piped to the \fBsystemd\-coredump\fP(8) program: .PP .in +4n .EX $ \fBcat /proc/sys/kernel/core_pattern\fP |/usr/lib/systemd/systemd\-coredump %P %u %g %s %t %c %e .EE .in .PP In this case, core dumps will be placed in the location configured for \fBsystemd\-coredump\fP(8), typically as \fBlz4\fP(1) compressed files in the directory \fI/var/lib/systemd/coredump/\fP. One can list the core dumps that have been recorded by \fBsystemd\-coredump\fP(8) using \fBcoredumpctl\fP(1): .PP .EX $ \fBcoredumpctl list | tail \-5\fP Wed 2017\-10\-11 22:25:30 CEST 2748 1000 1000 3 present /usr/bin/sleep Thu 2017\-10\-12 06:29:10 CEST 2716 1000 1000 3 present /usr/bin/sleep Thu 2017\-10\-12 06:30:50 CEST 2767 1000 1000 3 present /usr/bin/sleep Thu 2017\-10\-12 06:37:40 CEST 2918 1000 1000 3 present /usr/bin/cat Thu 2017\-10\-12 08:13:07 CEST 2955 1000 1000 3 present /usr/bin/cat .EE .PP The information shown for each core dump includes the date and time of the dump, the PID, UID, and GID of the dumping process, the signal number that caused the core dump, and the pathname of the executable that was being run by the dumped process. Various options to \fBcoredumpctl\fP(1) allow a specified coredump file to be pulled from the \fBsystemd\fP(1) location into a specified file. For example, to extract the core dump for PID 2955 shown above to a file named \fIcore\fP in the current directory, one could use: .PP .in +4n .EX $ \fBcoredumpctl dump 2955 \-o core\fP .EE .in .PP For more extensive details, see the \fBcoredumpctl\fP(1) manual page. .PP To (persistently) disable the \fBsystemd\fP(1) mechanism that archives core dumps, restoring to something more like traditional Linux behavior, one can set an override for the \fBsystemd\fP(1) mechanism, using something like: .PP .in +4n .EX # \fBecho "kernel.core_pattern=core.%p" > \e\fP \fB/etc/sysctl.d/50\-coredump.conf\fP # \fB/lib/systemd/systemd\-sysctl\fP .EE .in .PP It is also possible to temporarily (i.e., until the next reboot) change the \fIcore_pattern\fP setting using a command such as the following (which causes the names of core dump files to include the executable name as well as the number of the signal which triggered the core dump): .PP .in +4n .EX # \fBsysctl \-w kernel.core_pattern="%e\-%s.core"\fP .EE .in .\" .SH UWAGI Aby uzyskać zrzut pamięci działającego procesu, można użyć polecenia \fIgcore\fP programu \fBgdb\fP(1). .PP .\" Changed with commit 6409324b385f3f63a03645b4422e3be67348d922 .\" Always including the PID in the name of the core file made .\" sense for LinuxThreads, where each thread had a unique PID, .\" but doesn't seem to serve any purpose with NPTL, where all the .\" threads in a process share the same PID (as POSIX.1 requires). .\" Probably the behavior is maintained so that applications using .\" LinuxThreads continue appending the PID (the kernel has no easy .\" way of telling which threading implementation the user-space .\" application is using). -- mtk, April 2006 W wersjach jądra Linux do 2.6.27 włącznie, jeżeli pamięć zrzuca proces wielowątkowy (albo \- bardziej precyzyjnie \- proces, który dzieli swą pamięć z innym procesem utworzonym z flagą \fBCLONE_VM\fP funkcji \fBclone\fP(2)), to identyfikator procesu zawsze będzie dołączony do nazwy pliku zrzutu, chyba że ów identyfikator procesu już występuje w nazwie pliku, ponieważ w pliku \fI/proc/sys/kernel/core_pattern\fP użyto specyfikatora \fIp\fP (Jest to szczególnie użyteczne podczas stosowania przestarzałej implementacji LinuxThreads, w której każdy wątek procesu ma inny PID). .SH PRZYKŁADY Poniższy program pokazuje użycie składni potoku w pliku \fI/proc/sys/kernel/core_pattern\fP. Poniższa sesja powłoki demonstruje użycie tego programu (skompilowanego do pliku o nazwie \fIcore_pattern_pipe_test\fP): .PP .in +4n .EX $\fB cc \-o core_pattern_pipe_test core_pattern_pipe_test.c\fP $\fB su\fP Password: #\fB echo "|$PWD/core_pattern_pipe_test %p UID=%u GID=%g sig=%s" > \e\fP \fB/proc/sys/kernel/core_pattern\fP #\fB exit\fP $\fB sleep 100\fP \fB\(ha\e\fP # wpisz control+odwrotny ukośnik Quit (core dumped) $\fB cat core.info\fP argc=5 argc[0]= argc[1]=<20575> argc[2]= argc[3]= argc[4]= Całkowita liczba bajtów pliku core: 282624 .EE .in .SS "Kod źródłowy programu" \& .EX /* core_pattern_pipe_test.c */ #define _GNU_SOURCE #include #include #include #include #include #include #define BUF_SIZE 1024 int main(int argc, char *argv[]) { ssize_t nread, tot; char buf[BUF_SIZE]; FILE *fp; char cwd[PATH_MAX]; /* Zmienia bieżący katalog roboczy na katalog procesu, który generuje zrzut pamięci */ snprintf(cwd, PATH_MAX, "/proc/%s/cwd", argv[1]); chdir(cwd); /* Zapisuje wyjście do pliku "core.info" w tym katalogu */ fp = fopen("core.info", "w+"); if (fp == NULL) exit(EXIT_FAILURE); /* Wyświetla argumenty linii poleceń przekazane do programu filtrującego "core_pattern" */ fprintf(fp, "argc=%d\en", argc); for (int j = 0; j < argc; j++) fprintf(fp, "argc[%d]=<%s>\en", j, argv[j]); /* Zlicza bajty na standardowym wejściu (daje rozmiar zrzutu pamięci) */ tot = 0; while ((nread = read(STDIN_FILENO, buf, BUF_SIZE)) > 0) tot += nread; fprintf(fp, "Całkowita liczba bajtów pliku core: %zd\en", tot); fclose(fp); exit(EXIT_SUCCESS); } .EE .SH "ZOBACZ TAKŻE" \fBbash\fP(1), \fBcoredumpctl\fP(1), \fBgdb\fP(1), \fBgetrlimit\fP(2), \fBmmap\fP(2), \fBprctl\fP(2), \fBsigaction\fP(2), \fBelf\fP(5), \fBproc\fP(5), \fBpthreads\fP(7), \fBsignal\fP(7), \fBsystemd\-coredump\fP(8) .SH "O STRONIE" Angielska wersja tej strony pochodzi z wydania 5.10 projektu Linux \fIman\-pages\fP. Opis projektu, informacje dotyczące zgłaszania błędów oraz najnowszą wersję oryginału można znaleźć pod adresem \%https://www.kernel.org/doc/man\-pages/. .SH TŁUMACZENIE Autorami polskiego tłumaczenia niniejszej strony podręcznika są: Robert Luberda i Michał Kułach . Niniejsze tłumaczenie jest wolną dokumentacją. Bliższe informacje o warunkach licencji można uzyskać zapoznając się z .UR https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License w wersji 3 .UE lub nowszej. Nie przyjmuje się ŻADNEJ ODPOWIEDZIALNOŚCI. Błędy w tłumaczeniu strony podręcznika prosimy zgłaszać na adres .MT manpages-pl-list@lists.sourceforge.net .ME .