mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-11-29 09:03:20 -08:00
linux_demon: ptrace stop vs. clone notes - we cannot rely on the order!
This commit is contained in:
1 parent
cc82127537
commit
ca0764c2e2
1 file changed
+11
-3
@@ -2103,9 +2103,17 @@ dmn_ctrl_run(Arena *arena, DMN_CtrlCtx *ctx, DMN_RunCtrls *ctrls)
|
|||||||
//
|
//
|
||||||
case PTRACE_EVENT_CLONE:
|
case PTRACE_EVENT_CLONE:
|
||||||
{
|
{
|
||||||
// NOTE: kernel stopped the parent just before scheduling the child to
|
// NOTE(rjf): we get this event from the creator thread when it has
|
||||||
// give us a chance to prepare to trace it; next event for the child
|
// cloned itself to create a child. immediately after creation, the
|
||||||
// will be a PTRACE_EVENT_STOP
|
// child will raise a stop event. but importantly, the Linux kernel
|
||||||
|
// offers *NO GUARANTEES* about whether we receive the *clone* or
|
||||||
|
// the *stop* first.
|
||||||
|
//
|
||||||
|
// TODO(rjf): to account for this, upon STOP events of unrecognized
|
||||||
|
// threads, we need to accumulate a pending ID map, and then if a
|
||||||
|
// cloned thread's ID is in that map, we just immediately move it
|
||||||
|
// to a stopped state.
|
||||||
|
//
|
||||||
pid_t new_tid = 0;
|
pid_t new_tid = 0;
|
||||||
if(LNX_RETRY_ON_EINTR(ptrace(PTRACE_GETEVENTMSG, wait_id, 0, &new_tid)) >= 0)
|
if(LNX_RETRY_ON_EINTR(ptrace(PTRACE_GETEVENTMSG, wait_id, 0, &new_tid)) >= 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user