[Ltrace-devel] Multithreaded attach/detach fixes

Petr Machata pmachata at redhat.com
Wed Aug 24 10:39:32 UTC 2011


Hi there,

Regarding this:

> During detaching the process that ltrace attached to previously, the
> process is occasionally SIGSEGVed or SIGTRAPed.  I don't understand
> why that is happening, but it turns out it's not a regression at all.
> Both current master and an ancient and heavily patched version of
> ltrace that's currently in Fedora exhibit this behavior.  The detach
> works sometimes, which hopefully means that the underlying code is
> essentially sound, just hitting some weird race or something.

The cause for this is that the underlying code is _not_ sound--we detach
from the tracee regardless of what state it is in.  For example if the
process hits a breakpoint, and we decide to detach at that point, the IP
is left pointing mid-instruction.  Another scenario is that we let the
process singlestep and detach without catching the resulting event.
There are several such scenarios.

On the threading branch, this is aggravated by the fact, that we
distribute sigstops to stop threads (we don't want to leave those
pending), and that there are several threads, so the chances of hitting
the edge case are higher.

Anyway, a fix for this landed on a threading-revised-revised branch,
together with a fix for attach, which was racy.

PM



More information about the Ltrace-devel mailing list