---
title: "Qt Ubuntu 12.10 error ptrace: Operation not permitted"
author: "hellobin"
date: "2013-07-04T11:30:50Z"
tags: []
categories: ["开源软件"]
slug: "qt-ubuntu-12-10-error-ptrace-operation-not-permitted"
draft: false
lastmod: "2013-07-04T11:30:50Z"
id: 1898337
url: "https://hellobinfeng.iteye.com/blog/1898337"
---

While trying to debug for the first time I got this 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


Solution:
```

On Ubuntu versions after 10.10 you'll run into this in more related applications, such as QtCreator. It is a security *feature* of Ubuntu that prevent the debugger to attach to processes not owned by him.

This is filed as a [bug #3509 against QtCreator](https://bugreports.qt-project.org/browse/QTCREATORBUG-3509). To work around this issue, do this:

- temporary solution (won't survive a reboot):
  
  ```
   echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
  ```
- In a file `/etc/sysctl.d/10-ptrace.conf` (should already exist), change the value of`kernel.yama.ptrace_scope` to `0` and then reload the configuration: `sudo sysctl -p`.

I'm explicitly posting the temporary solution, as you probably don't want to keep this feature disabled on a regular machine for security reasons.

 

Ref: [http://askubuntu.com/questions/244336/receiving-error-while-trying-to-debug-in-qtproject](http://askubuntu.com/questions/244336/receiving-error-while-trying-to-debug-in-qtproject)