famzah / popen-noshell

A much faster popen() and system() implementation for Linux
68 stars 13 forks source link

workaround issue with gdb missing breakpoints #10

Closed dkondor closed 8 years ago

dkondor commented 8 years ago

I've recently found that on my system (Ubuntu 16.04, Linux 4.4.0, gcc 5.3.1, gdb 7.11.1), if I try to debug a program using popen_noshell() calls, gdb misses breakpoints after the subprocess creation.

I've found that this can be worked around by adding either CLONE_UNTRACED or CLONE_VFORK as an extra flag to the clone() system call (as far as I understand, the first option explicitly forces gdb not to follow the newly created process, while I have no idea how the second one works).

I'm not sure if it's a bug in gdb or expected but undocumented behavior; I don't remember exactly, but it's very probable that previous gdb versions did not have this problem, but I don't have easy access to any right now to test this.

I've submitted a bug to the gdb developers which includes a minimal test case as well here https://sourceware.org/bugzilla/show_bug.cgi?id=20322 -- given the large number of bugs they have there, I decided to post here as well for better reference in case someone runs into the same problem

famzah commented 8 years ago

Hi, thanks for the info. Keep us posted with any additional details.