Qt Creator, ptrace: operation not allowed. What is a permanent solution?

When debugging C++ in Qt creator I get the following error

 ptrace: Operation not permitted. Could not attach to the process. Make sure no other debugger traces this process. Check the settings of /proc/sys/kernel/yama/ptrace_scope For more details, see /etc/sysctl.d/10-ptrace.conf 

Here is a workaround: Error trying to debug in QtProject

  • workaround (will not reboot):

    echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

But it is hard to run the same code in the terminal every time I start my PC to use Qt.

 What is the permanent solution for this? 
+44
c ++ qt linux-kernel qt5 linuxmint
Mar 01
source share
3 answers

If you are using Ubuntu,

The recommended way to enable the required ptrace kernel parameter (outlined by qtcreator) is to edit /etc/sysctl.d/10-ptrace.conf

 sudo vim /etc/sysctl.d/10-ptrace.conf 

Then change

 kernel.yama.ptrace_scope = 1 

to

 kernel.yama.ptrace_scope = 0 

Save

then apply:

 $ sudo sysctl --system -a -p|grep yama kernel.yama.ptrace_scope = 0 

run

 man sysctl 

for more information.

+54
Nov 21 '14 at 15:58
source share

I got an answer.

  • Go to the /etc folder with root privileges.

  • Locate the rc.local file.

  • Open it in a text editor such as gedit and add the following code there
  • echo 0 | tee /proc/sys/kernel/yama/ptrace_scope

Restart your computer and you can work out the debugger perfectly.

+24
Mar 03 '14 at 8:13
source share

I found an answer that works for me on ubuntu in the bottom link and the loan goes to dstzcxr

https://askubuntu.com/a/501271/395583

Just uncheck (or check - run - uncheck if it is unchecked for some reason) the "Run in terminal" field in "Projects" (on the left panel) - "Run" tab - "Run".

+4
May 27, '15 at 15:16
source share



All Articles