LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* Problem with PTRACE_EVENT_CLONE in 2.6.27
@ 2008-11-06 10:10 Martin Baulig
  0 siblings, 0 replies; only message in thread
From: Martin Baulig @ 2008-11-06 10:10 UTC (permalink / raw)
  To: linux-kernel

Hello,

I am developing a debugger and recently run into a strange problem
with ptrace() which showed up between 2.6.25.16 and 2.6.28-rc3.

I'm using

	int flags = PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK |
PTRACE_O_TRACEVFORK |
		PTRACE_O_TRACEEXEC;

	ptrace (PTRACE_SETOPTIONS, pid, 0, flags);

after starting the target application and then do a

	ret = waitpid (pid, status, WUNTRACED | __WALL | __WCLONE);

in a special worker thread.

My problem is that with recent kernels, I sometimes get the initial
SIGSTOP event for a newly created thread before the `PTRACE_EVENT_CLONE'
event for that thread.

This causes two problems for me:

a) I'm getting a SIGSTOP for an unknown PID, so I have to decide what
   to do with it.

   It seems that ptrace (PT_GETRETGS) on that PID sometimes works and
   sometimes doesn't - what's going on here ?  Can I debug the new
   thread just after receiving its initial SIGSTOP or do I need to
   wait until the `PTRACE_EVENT_CLONE' ?


b) After getting the PTRACE_EVENT_CLONE, there seems to be no reliable
   way for me to wait until this new thread has stopped.

   If I understand things correctly, you can't waitpid() on a thread
   which is already stopped, so how do I check whether the newly
   created thread has already stopped ?

I put some really bad hack to work around this problem into the
development version of our product, but I'd be very happy to hear about
an official solution.

I'm not subscribed to the list, so please Cc: me on all replies.

Thanks,
Martin Baulig

-- 
Martin Baulig - martin@novell.com
Novell GmbH, Düsseldorf
GF: Volker Smid, Djamel Souici; HRB 21108 (AG Düsseldorf)



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-11-06 10:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-06 10:10 Problem with PTRACE_EVENT_CLONE in 2.6.27 Martin Baulig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).