[arch-general] GDB does not work, sometimes

Rodrigo Rivas rodrigorivascosta at gmail.com
Sat Nov 23 07:14:08 EST 2013


Hi!

I'm having a very weird problem with gdb. I hadn't used the debugger for
some time, so I'm not sure for how long it has been broken...
The problem is that the debugged program does not stop in any breakpoing,
exception, signal... nothing. Just as if it weren't being debugged.

First I thought that it was a problem with GDB and I was ready to submit a
bug report, but then... I have gdb-7.6.1-1 and that has been in the
repositories for several months. Surely someone noticed if it didn't work
at all for so long!

So I started investigating, but how to debug a broken debugger? Long story
made short:

* gdb fails even with the simplest program (`int main() {}`). I even
disabled the start-up stcripts with "gdb -n", no difference.
* it fails with programs compiled with both gcc and clang.
* it does not fail if I debug as root.
* it does not fail if I debug in a VT instead of a PTY.

So it looks like some kind of permission issues. Maybe something related to
the recent SELinux changes?
Googling around I've found that setting /proc/sys/kernel/yama/ptrace-scope
to 0 solves the issue. But it should not work this way: the idea of this
key is that by default only the parent of a process can ptrace/debug it.
And certainly, gdb is the parent of the processes it spawns (yes, I've
checked it).
Moreover, running "ptrace ls" works fine, so why not "gdb ls"?

And what's the difference between a VT and a PTY? That I cannot understand.

For now I can workaround with the "yama/ptrace-scope", but does anybody
know what is happening?

Best regards.
-- 
Rodrigo


More information about the arch-general mailing list