|
|
Log in / Subscribe / Register

Restartable sequences and ops vectors

Restartable sequences and ops vectors

Posted Nov 1, 2017 4:37 UTC (Wed) by jthill (subscriber, #56558)
Parent article: Restartable sequences and ops vectors

I don't understand why it's worth any effort to singlestep these. You can't singlestep through a LL…SC sequence and yet code that uses those isn't regarded as un-debuggable, why do the techniques used to debug those not work acceptably here?


to post comments

Restartable sequences and ops vectors

Posted Nov 4, 2017 21:10 UTC (Sat) by compudj (subscriber, #43335) [Link]

The techniques used by gdb to handle LL/SC critical sections are pretty much a pattern-based heuristics. They break as soon as you craft a critical section with a pattern unexpected by gdb.

I'm providing a __rseq_table section with the rseq fast-paths in user-space, which contains the start address, length, and abort address required by gdb to understand how to better handle single-stepping wrt those critical sections. Architectures that require to single-step with explicit breakpoint at each instruction will need to use this to tell gdb that the kernel may branch off elsewhere in those critical sections. Those will require improvements to debuggers to properly handle having the kernel branch out of a rseq critical section. It's one thing to improperly single-step an application (skipping instructions), but it's another to make the application hang in a rseq critical section when executed under single-stepping. The first case can be fixed by teaching debuggers about rseq. However, we don't want to cause existing applications to hang because they are single-stepped.

For architectures that provide hw-assisted single-stepping, the only thing we need is to have a fall-back that can allow some kind of progress even though the instruction sequence is being restarted (cpu_opv provides this).

There are also other unlikely scenarios that could cause the instruction sequence to always be restarted. For instance, unexpected page faults, which could be caused by memory protection from a memory access analyzer tool, or simply having the kernel trapping a fast-path instruction that we would not have expect it to trap from a user-space perspective.

Therefore, having a fall-back that ensures progress is a very good guarantee to ensure robustness of the programs using restartable sequences. Given that some major use-cases for rseq are memory allocators, we can expect glibc and other libraries (jemalloc) to start using under the hood without knowledge from the applications. The last thing we want is that a glibc upgrade would cause applications to hang in a rseq loop when being debugged.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds