Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Valgrind showing error calling pr_set_ptracer, vgdb might block

Tags:

c

valgrind

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.

Here the snippet of error:

==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
like image 273
Yogesh_Singh Avatar asked Jul 25 '19 16:07

Yogesh_Singh


1 Answers

The vgdb executable (part of valgrind) is used to 'connect' to valgrind to either launch monitor commands or make the link between gdb and your process running under valgrind. If your process is blocked in a syscall, vgdb needs to 'wake up' your process and for this must be able to 'ptrace' your process. Depending on how the security is configured on your system, valgrind might 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 long as your process is blocked in a syscall. So, unless you have a critical need to debug your process when blocked in a syscall, or launch a monitor command when blocked in a syscall, there is no consequences.

This error is however not expected. So, please report a bug on valgrind bugzilla. Attach the output of: cat /proc/sys/kernel/yama/ptrace_scope Also, it would be nice if you could use strace -f valgrind and extract the reason why the syscall prctl (PR_SET_PTRACER) is failing (in particular the errno).

like image 185
phd Avatar answered Oct 14 '22 16:10

phd