On Fri, 15 Apr 2016, Alexander Monakov wrote:
> On Fri, 15 Apr 2016, Michael Matz wrote:
> > Replace first nop with a breakpoint, handle rest of patching in breakpoint 
> > handler, patch breakpoint insn last, no need to atomically patch multiple 
> > instructions.
> 
> Alternatively: replace first nop with a short forward branch that jumps over
> the rest of the pad, patch rest of the pad, patch the initial forward branch.

I've noticed an issue in my (and probably Michael's) solution: if there's a
thread that made it past the first nop, but is still executing the nop pad,
it's unsafe to replace the nops.  To solve that, it suffices to have a forward
branch in place of the first nop to begin with (i.e. have the compiler emit
it).  But if Szabolcs' two-instruction sequence in the adjacent subthread is
sufficient, this is moot.

Alexander

Reply via email to