核心转储文件名被截断

发布于 2024-08-11 06:59:54 字数 310 浏览 12 评论 0原文

鉴于 /proc/sys/kernel/core_pattern 中的配置设置为 /cores/core.%e.%p,核心转储根据模式命名,但是对于进程运行具有长名称的可执行文件,例如 SampleCrashApplication,生成的核心文件将包含截断的可执行文件名称:/cores/core.SampleCrashAppl.9933

是什么原因导致的? man core 页面仅讨论生成的核心文件名的最大大小为 128(2.6.19 之前的内核为 64)

Given the configuration in /proc/sys/kernel/core_pattern set to /cores/core.%e.%p, core dumps are named according to pattern, however for processes running executables with long names e.g. SampleCrashApplication, the generated core file will contain a truncated executable name: /cores/core.SampleCrashAppl.9933

What is causing this ? The man core page talks only about maximum size of the resulting core filename being 128 (64 for kernels before 2.6.19)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

2024-08-18 06:59:54

代码可以在 exec.c 此处

该代码将根据模式复制核心名称,直到第一个百分比(给出/cores/core)。它将按百分比递增并处理“e”。处理“e”部分的代码根据 current->comm 结构使用 snprintf 打印出模式。

这是可执行文件名称(不包括路径),截断为值 TASK_COMM_LEN。由于这被定义为 16 个字符(至少在我发现的内核中),因此 SampleCrashApplication 被截断为 15 + 1 个字符(1 表示末尾的空字节),这解释了为什么您会得到截断的核心转储名称。

至于为什么这个结构会截断名称 TASK_COMM_LEN,这是一个更深层次的问题,但它是内核内部的东西,并且有一些讨论 此处

The code for this can be found in exec.c here.

The code is going to copy the corename based on the pattern up to the first percentage (giving /cores/core.). At the percentage it's going to increment and process the 'e'. The code for processing the 'e' part prints out the pattern using snprintf based on the current->comm structure.

This is the executable name (excluding path) TRUNCATED to the value TASK_COMM_LEN. Since this is defined as 16 characters (at least in the Kernel I found) then SampleCrashApplication is truncated to 15 + 1 characters (1 for the null byte at the end) which explains why you get your truncated core dump name.

At to why this structure truncates the name TASK_COMM_LEN, that's a deeper question, but it's something internal to the kernel and there's some discussion here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文