QtCreator: "ptrace: Operation not permitted." in Debug mode

Bug #1156674 reported by Geier
26
This bug affects 5 people
Affects Status Importance Assigned to Milestone
qtcreator (Ubuntu)
Won't Fix
Undecided
Unassigned

Bug Description

Debugging with Qt Creator does not work. Upon entering debug mode, the error message in the attached screenshot is presented (translation: ptrace: Operation not permitted). The associated console window stays open without any possibility of interaction.

More info and a temporary fix for users can be found here: http://www.deder.at/wordpress/?p=307

More info on the error cause: https://wiki.ubuntu.com/SecurityTeam/Roadmap/KernelHardening#ptrace

How to reproduce:
- In QtCreator, create a new "Plain C" or "Plain C++" project.
- Set a breakpoint in the generated main function
- click the Debug-button in the lower left bar.

Expected: Debug mode opens with the ability to set breakpoints, edit watches and step through the source code.

What happens: See attached screenshot. Debugging doesn't work.

ProblemType: Bug
DistroRelease: Ubuntu 13.04
Package: qtcreator 2.7.0~beta-0ubuntu2
ProcVersionSignature: Ubuntu 3.8.0-11.20-generic 3.8.2
Uname: Linux 3.8.0-11-generic x86_64
ApportVersion: 2.9.1-0ubuntu1
Architecture: amd64
Date: Mon Mar 18 16:18:47 2013
InstallationDate: Installed on 2013-03-08 (9 days ago)
InstallationMedia: Ubuntu 13.04 "Raring Ringtail" - Alpha amd64 (20130308)
MarkForUpload: True
SourcePackage: qtcreator
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Geier (geier-de) wrote :
Geier (geier-de)
description: updated
summary: - QtCreator: "ptrace: operation not allowed" in Debug mode
+ QtCreator: "ptrace: Operation not permitted." in Debug mode
Geier (geier-de)
description: updated
Revision history for this message
Felix Geyer (debfx) wrote :

This is a security feature not a bug.
The wiki page you linked has instructions on how to disable it if you wish to do so.
Debugging works when you start the application from Qt Creator as opposed to attaching it to an already running process.

Changed in qtcreator (Ubuntu):
status: New → Invalid
Revision history for this message
Geier (geier-de) wrote :

No.

As explained in my "How to reproduce" section, Debugging does *not* work when you start the application from Qt Creator.

Felix Geyer (debfx)
Changed in qtcreator (Ubuntu):
status: Invalid → New
Revision history for this message
Paulo Sequeira (psequeirag) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in qtcreator (Ubuntu):
status: New → Confirmed
Revision history for this message
Simon K (octav14n) wrote :

The "ptrace" error is a result of running your app in an terminal.

To be able to debug you could either deactivate the "ptrace-restrictions" or disable the terminal.
To disable the terminal you click:
 1. Projects (in the side menu between Debug and Packaging)
 2. Run (in the second line from the top, it says: Desktop Build _Run_)
 3. Empty the check box "Run in terminal"

Revision history for this message
Ian Nicholson (imnichol) wrote :

The solution by Simon K stops the ptrace error, but I then I would get prompted that:
"The debugger could not load the debugging helper library.
The debugging helper is used to nicely format the values of some Qt and Standard Library data types. It must be compiled for each used Qt version separately. In the Qt Creator Build and Run preferences page, select a Qt version, expand the Details section and click Build All." with options to "open qt options", "turn off helper usage", show details", and "continue anyway".
If I selected "continue anyway", the project appears to begin debugging, but does not execute.

Revision history for this message
Max Beikirch (max-beikirch-3) wrote :

I confirm this behaviour.

Revision history for this message
omkar ashok kulkarni (omkarvit007) wrote :

First of all it's not bug. It's for security purposes.

Some things about PTRACE:
1)The PTRACE system is used for debugging.
2)With it, a single user process can attach to any other dumpable process owned by the same user. A PTRACE scope of "0" is the more permissive mode. A scope of "1" limits PTRACE only to direct child processes.

This is the stuff from "/etc/sysctl.d/10-ptrace.conf" file.

So for successful debugging with "Qt Creator" you have two options:
Option 1:
1. Open "Qt Creator" with superuser privileges. For this open terminal type command "sudo -s" , then enter password.
2.Then enter command "qtcreator".

Option 2:
1.Open terminal type "sudo -s", then enter password.
2.Then go to directory "/proc/sys/kernel/yama/" by using "cd" command.
3.In this directory open "ptrace_scope" file by using "gedit ptrace_scope" command. (You can use any editor to edit file I've used here gedit).
4.In this file default value is "1" , so change this value to "0".
5.Save this file and then close it.

Now you can surely do debugging in "Qt Creator".

That's it.

Revision history for this message
Geier (geier-de) wrote :

Thanks for your suggestions, omkar, but both are not acceptable "fixes" for the end user.

Option 1 means running QtCreator and the spawned application as root, which is frowned upon for good reasons. Debugging should work without sudo.

Option 2 is already outlined in the link I posted in the original bug submission, so it's nothing new. But it disables the security feature for all application, which is also not desirable.

Even if option 1 or 2 were acceptable, it's certainly not acceptable that the user has to change the system configuration by herself to get debugging to work. It should work out of the box. So it's definitaly a bug.

Revision history for this message
Zoltan Balogh (bzoltan) wrote :

Following the discussion I am not sure if we as the distro can and will fix this issue.

If you think it is a bug in the upstream code then please file a bug against the upstream project. Or please suggest a doable change in the Ubuntu release.

Changed in qtcreator (Ubuntu):
status: Confirmed → Won't Fix
Revision history for this message
Ian Nicholson (imnichol) wrote :

For the record, this error occurs when I tried to run the default C++ project.
Ubuntu is shipping a development environment that is broken for a common use case. Is there some way to just disable ptrace so that I can build and run a project? Maybe that could be set as default.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.