Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 May 2010 20:07:27 -0700
From:      Ben Widawsky <widawsky@gmail.com>
To:        gljennjohn@googlemail.com
Cc:        freebsd-current@freebsd.org
Subject:   Re: PT_ATTACH resumes suspended process
Message-ID:  <AANLkTilPuhosrlpaK3LLYJeT0FujwtiLuzIcYbIQ_tTl@mail.gmail.com>
In-Reply-To: <20100508135031.00fcd71e@ernst.jennejohn.org>
References:  <y2y121e074a1005071352re9572669of2c2a10f0e754ee3@mail.gmail.com> <20100508135031.00fcd71e@ernst.jennejohn.org>

index | next in thread | previous in thread | raw e-mail

> Looking at the sendsig label in sys_process.c:kern_ptrace() makes it clear
> what's happening - in your testing the process was already stopped so
> the code sets td_xsig to SIGSTOP and wakes it up to send it the signal.
>
> But td_xsig doesn't seem to be used anywhere to set pending signals.  Maybe
> I missed the place where that happens.
>
> The assumption seems to be that a process being traced will only be
> stopped if the debugger is already attached and that any signals being
> sent to it are coming from the debugger itself.
>
> This assumption is wrong if the process being attached to was already
> stopped.
>
> It seems to me that checking for req == PT_ATTACH when the process is
> already stopped and doing a break; in that case might be a solution.

Could you be more specific? It seems to me even if you had a special case in
kern_ptrace to handle PT_ATTACH when the process is suspended, the code would
end up being almost identical to ptracestop(). Unless I didn't follow you.

Because of this, I think what I suggested initially, esentially resuming the
thread with a pending SIGSTOP (by checking the value of xsig when the thread
switches back in issignal) would be a better approach. The hack I put in bothers
me a bit because some of the other threads may resume, and even run for a while,
but it's still better than the existing behavior.


help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTilPuhosrlpaK3LLYJeT0FujwtiLuzIcYbIQ_tTl>