Bug 224277 - [tcf] ptrace attach race condition
Summary: [tcf] ptrace attach race condition
Status: RESOLVED FIXED
Alias: None
Product: TCF
Classification: Tools
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 0.1   Edit
Assignee: Felix Burton CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2008-03-26 22:53 EDT by Felix Burton CLA
Modified: 2013-06-05 08:05 EDT (History)
3 users (show)

See Also:


Attachments
fix for ptrace attach race condition (10.77 KB, patch)
2008-03-26 22:53 EDT, Felix Burton CLA
no flags Details | Diff
updated fix for ptrace attach race condition (23.61 KB, patch)
2008-03-31 13:51 EDT, Felix Burton CLA
mober.at+eclipse: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Felix Burton CLA 2008-03-26 22:53:53 EDT
Created attachment 93741 [details]
fix for ptrace attach race condition

The attached patch fixes a race condition when attaching to newly created processes.  The new method is using PTRACE_TRACEME on the child process.  The context create notification is delayed until waitpid() reports that the context is stopped.  Before this point no ptrace() calls should be made.

A second issue was that when an attached process calls fork or clone the child stopped notification can come before the fork/clone notification.  Prior to this change the stop notification was dropped which caused the state logic to be out of sync.

With this patch the contextAdded event arrives after the return value of the command that created process.  This seems incorrect, but the diagnostic tests seems to work.
Comment 1 Martin Oberhuber CLA 2008-03-27 03:47:11 EDT
Patch is 76 lines of code.

Felix did you write everything yourself or reference any other code? - Please add our default legal message on this bug, as per
  http://www.eclipse.org/dsdp/tm/development/committer_howto.php#external_contrib

Eugene can you review and commit the patch, add the contributed kwd
and add to our tm-log.csv IP Log.
Comment 2 Felix Burton CLA 2008-03-31 13:51:52 EDT
Created attachment 94266 [details]
updated fix for ptrace attach race condition 

Updated patch that fixes the issue with contextAdded events arriving after the reply.

Patch is writen by me without referencing any 3rd party material.
Comment 3 Eugene Tarassov CLA 2008-03-31 17:05:12 EDT
Commited to SVN
Comment 4 Doug Schaefer CLA 2011-05-17 10:50:17 EDT
Moving bugs to new home for IP log.
Comment 5 Martin Oberhuber CLA 2013-06-05 06:35:54 EDT
Bulk update: Marking all bugs from the TM era (before June 2011) target 0.3