QtCreator: ptrace operation not permitted

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.

ptrace does not permit this :)

Fixing 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 :)

Why does the error occur?

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.


  1. Reply
    Enrique June 29, 2012

    Hi Daniel,

    I’ve found this article looking for a solution to the same problem. After trying your fix and verifying that it actually works, I’ve realized that the problem only happens when running the program in a terminal. If you disable the “Run in terminal” switch in the project configuration, the error does not happen at all.

    • Reply
      Daniel Eder July 20, 2012

      I finally found some time to verfiy this and I can confirm it – so that may be a great workaround.

  2. Reply
    Mahmoud December 21, 2012

    I have done this but there still the same error here.

    • Reply
      Mahmoud December 21, 2012

      Do i have to reboot ?

      • Reply
        Daniel Eder December 22, 2012

        The temporary solution does not require a reboot but the permanent solution (changing the ptrace configuration) will require a reboot.

  3. Reply
    Sergiu Bivol April 4, 2013

    Because ‘sudo’ applies only to the command following it (‘echo’ in this case), the correct command for the temporary fix is:
    echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

    Thank you for the solution and the explanation!

  4. Reply
    offtza June 3, 2013

    Best command is:

    sudo sysctl kernel.yama.ptrace_scope=0

  5. Reply
    Alexey July 9, 2013

    Daniel, thanks a lot for this fix! I used the permanent one. And thanks a lot to Mahmoud for the reboot question. :D

  6. Reply
    benhuan July 16, 2013

    Thank you very much

  7. Reply
    ldiggy October 14, 2013

    Thanks player!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>