Debugging Qt in Ubuntu reports ptraceoperationnotpermitted

Source: Internet
Author: User
QtCreator is a very good IDE that can be used to develop Qt applications and General C ++ applications. However, when you debug an application on Ubuntu, errors may occur (such as memory access errors). The QtCreator dialog box is displayed, showing QtCreator: ptraceoperationnotpermitted, as shown in. Solution: this error occurs especially in Versions later than Ubuntu11.04. There are two ways to solve this problem.

QtCreator is a very good IDE that can be used to develop Qt applications and General C ++ applications. However, when you debug an application on Ubuntu, errors may occur (such as memory access errors). The QtCreator dialog box is displayed, showing QtCreator: ptrace operation not permitted, as shown in.

Solution

This error especially occurs in Versions later than Ubuntu 11.04. To solve this problem, there are two methods, both of which require the root permission.

The first solution can temporarily solve this problem, but the next restart of the system will fail. Set the content of the/proc/sys/kernel/yama/ptrace_scope Virtual File to 0 and run the following command:

Sudo echo 0>/proc/sys/kernel/yama/ptrace_scope

The second solution can solve this problem permanently by editing the/etc/sysctl. d/10-ptrace.conf file and setting

Kernel. yama. ptrace_scope = 0 (1 by default)

This will also take effect at the next startup.

Cause

In Versions later than Ubuntu 11.04 ("Natty Narwhal"), a security mechanism called ptrace scope is introduced. This mechanism prevents users from accessing the memory and status of the currently running process, which causes the debugger of QtCreator to not work properly. This security mechanism can prevent malicious software from attaching to other processes (such as SSH or GPG), read program memory, and cause security problems.

------------------------------------------ Split line ------------------------------------------

Another example:

Click the icon to run the qt creator. An error is reported during debugging,

Obviously, the permission is insufficient. The solution is to use sudo./qtcreator instead.

You can create

Shortcut, so you do not need to cd to the directory where the program is located every time.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.