Recently I reactivated my development environment for Qt in my Ubuntu. I started to work on QtDropbox (I did not write about that one, but will soon) and eventually there was a situation that I wanted to investigate further – some strange crash in one of the routines, but that’s not the actual topic I want to share with you.
Maybe you encountered it your self. If you start the Debugger you receive this error message. I got that one by using QtCreator but I assume there are many more possibilites to get it.
There is a temporary and a permanent fix for this. You’ll require root access rights for both. The temporary solution first. Just run this in your command line:
sudo echo 0 > /proc/sys/kernel/yama/ptrace_scope
This will allow you to run the debugger for your current session – but it will be reset as soon as you restart your computer. For a more permanent solution edit /etc/sysctl.d/10-ptrace.conf and set
kernel.yama.ptrace_scope = 0
That’s all if you only want it to work. Read on if you are interested in the reasons for this error
Since Ubuntu 11.04 (“Natty Narwhal”) a security feature named ptrace scope was implemented. This feature prevents users from accessing memory and states of currently running processes – and thus caused that error. Why was such a feature implemented? Because if any user can access the memory it is possible to write software that attaches to a currently running process (like SSH or any GPG agent or anything else) and read the memory of that application. If you are a crafty (and evil minded) programmer you could exploit that to find out sensitive data this process contains. See here for details.