Category: GDB

gdb attach fails with ptrace: Operation not permitted

Today I ran into a weird problem while using NetBeans. I could not attach to my own process with GDB. The process ran under my UID, but GDB refused to attach.

The issue is explained here:

https://wiki.ubuntu.com/SecurityTeam/Roadmap/KernelHardening#ptrace%20Protection

To solve temporary:

$ sudo su
$ echo 0 > /proc/sys/kernel/yama/ptrace_scope

To solve permanently:

edit as root /etc/sysctl.d/10-ptrace.conf and set

kernel.yama.ptrace_scope = 0

WordPress Themes