Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem that linux does not generate core files?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "how to solve if linux does not produce core files". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Linux does not generate core files solution: 1, check the existence of the Core dump directory and set the process has write access to the directory; 2, check whether the service program calls seteuid (); 3, set a large enough Core file size limit; 4, modify profile, and so on.

This article operating environment: linux5.9.8 system, Dell G3 computer.

What if linux does not generate core files? Why is the core file not generated?

First, make sure that the directory where the Core dump is stored exists and that the process has write permission to the directory.

The directory where the Core dump is stored is the current directory of the process, which is usually the directory where the process was started when the command was issued. However, if you start through a script, the script may modify the current directory, and the real current directory of the process will be different from the directory in which the script was executed. At this point, you can look at the target of the "/ proc//cwd" symbolic link to determine the real current directory address of the process. Processes started by system services can also be viewed in this way.

Second, if the program calls seteuid () / setegid () to change the valid users or groups of processes, the system will not generate Core dump for these processes by default.

Many services call seteuid (), such as MySQL, and no matter what user you use to run mysqld_safe to start MySQL,mysqld, the valid user is always the msyql user. If you run a program as user A, but the user of the program you see in ps is B, then these processes are calling seteuid. In order for these processes to generate Coredump, you need (echo "1" > / proc/sys/kernel/suid_dumpable).

Third, this is generally known, is to set a large enough Core file size limit.

The size of the Core file generated when the program crashes is the amount of memory consumed when the program is running. However, the behavior of a program when it crashes can not be estimated according to its normal behavior, such as buffer overflow and other errors may cause the stack to be destroyed, so it is common for the value of a variable to be modified into a mess. then the program uses this size to request memory, which may cause the program to take up more memory than usual. Therefore, no matter how little memory is used when the program is running normally, it is better to make sure that the Core file is generated and the size limit is set to unlimited.

4. Add to / etc/profile:

Ulimit-c unlimited > / dev/null 2

5. For programs that are generally started on CLI, if you set:

Ulimit-c unlimited

The core dump file can be generated when terminating outside the program. But for programs running in daemon mode, the main difference between programs started by CLI and those started by CLI is the running environment of the process, including

Cwd (current working directory). If you define the format of the core file in a relative path, for example, define / proc/sys/kernel/core_pattern as:

Core-%e-%p-%t

Generally speaking, the cwd of the daemon file is /, and you can view it through / proc//cwd, usually connecting to the / directory. If the user does not have write permission to this directory, then the core dump file will not be generated.

The most direct solution is to change / proc/sys/kernel/core_pattern to the absolute path: / data/coredump/core-%e-%p-%t

And guarantee that this will be the basic OK.

Modify the core dump file format in the / proc/sys/kernel/core_pattern file to an absolute path, such as:

/ data/coredump/core-%e-%p-%t

When will the core file not be generated?

Core files are not generated under the following conditions:

(a) the process is set-user-ID, and the current user is not the owner of the program file

(B) the process is set-group-ID, and the current user is not the group owner of the program file

(C) the user does not have permission to write the current working directory

(d) the document is too large. Permissions for core files (assuming the file does not exist before) are usually user read / write, group reads, and other reads.

This is the end of the content of "how to solve if linux does not generate core files". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report