问题描述
我正在使用 Valgrind 来查找我的 C 程序的内存泄漏,尽管它看起来运行良好并显示分配和释放的内存.但是,我想知道它为什么会抛出这个错误以及它的后果是什么.
I am using Valgrind to find memory leaks of my C program and although it looks like it is running fine and showing allocated and freed memory. But, I want to know why it is throwing this error and what are its consequences.
这里是错误的片段:
==483== Memcheck, a memory error detector
==483== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==483== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==483== Command: ./main ../old\ projects
==483==
==483== error calling PR_SET_PTRACER, vgdb might block
推荐答案
vgdb 可执行文件(valgrind 的一部分)用于连接"到 valgrind要么启动监视器命令,要么在 gdb 和你的在 valgrind 下运行的进程.如果您的进程在系统调用中被阻塞,则 vgdb 需要唤醒"您的进程为此,您必须能够跟踪"您的流程.根据系统上安全性的配置方式,valgrind可能必须告诉内核 ptrace 本身没问题.这是使用系统调用 prctl (PR_SET_PTRACER) 完成的.如果此系统调用失败,您会看到此消息.结果是 vgdb 无法连接到您的进程,只要因为您的进程在系统调用中被阻止.因此,除非您在阻塞时有必要调试您的进程系统调用,或在系统调用中被阻止时启动监视器命令,有没有任何后果.
The vgdb executable (part of valgrind) is used to 'connect' to valgrindto either launch monitor commands or make the link between gdb and yourprocess running under valgrind.If your process is blocked in a syscall, vgdb needs to 'wake up' your processand for this must be able to 'ptrace' your process.Depending on how the security is configured on your system, valgrindmight have to tell the kernel that ptrace itself is ok.This is done using the syscall prctl (PR_SET_PTRACER).If this syscall fails, then you see this message.The consequence is that vgdb cannot connect to your process as longas your process is blocked in a syscall.So, unless you have a critical need to debug your process when blocked ina syscall, or launch a monitor command when blocked in a syscall, there isno consequences.
然而,不会出现此错误.所以,请在 valgrind bugzilla 上报告一个错误.附上输出: cat/proc/sys/kernel/yama/ptrace_scope另外,如果您可以使用 strace -f valgrind 那就太好了并提取系统调用 prctl (PR_SET_PTRACER) 失败的原因(特别是错误号).
This error is however not expected.So, please report a bug on valgrind bugzilla.Attach the output of: cat /proc/sys/kernel/yama/ptrace_scopeAlso, it would be nice if you could use strace -f valgrindand extract the reason why the syscall prctl (PR_SET_PTRACER) is failing(in particular the errno).
这篇关于Valgrind 显示调用 pr_set_ptracer 时出错,vgdb 可能会阻塞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!