New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New kernel API proposal (NetBSD) #207

Open
krytarowski opened this Issue Feb 18, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@krytarowski

krytarowski commented Feb 18, 2018

I'm researching an addition of a new kernel API in NetBSD. My motivation is to support the StopTheWorld() operation that is used in few types of G/C (including bdwgc) and in LLVM LSan.

pinspect(2) - process self-introspection

int
pinspect(int request, void *addr, int data);

Operations:

  • PI_ENABLE - stop the world -- suspend execution of all the (native) threads besides the calling one; the change of state of threads is invisible to the processes unless executed under a debugger (no signals sent, etc)
  • PI_DISABLE - resume the world
  • PI_GETREGS - addr specifies destination buffer; data specifies (native) thread id; process must be stopped [or better PI_GETCONTEXT to get ucontext(2)]

This interface resembles a little bit stripped down ptrace(2) for self-debugging.

Does this make sense? The current implementation of StopTheWorld() in LSan for Linux is awful: vfork(2)/clone(2) + ptrace(2) + editing shared data.

I would like to reuse the same interface for bdwgc as well. I expect that the kernel API will be immune to threading issues (as long as we have a correct kernel), independent from pthread(3), invisible to the world (like ps(1), top(1)), not-conflicting with debuggers (ptrace(2)), simple to use.. and hopefully quick for multiple threads.

I intend to craft something that will be maximally useful and if possible open for other use-cases (suggestions?) of process self-introspecting.

https://github.com/llvm-mirror/compiler-rt/blob/8d93d94612443a03d2e211d944e3097f66ba75d5/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc

@ivmai ivmai changed the title from New kernel API proposal to New kernel API proposal (NetBSD) Feb 19, 2018

@ivmai

This comment has been minimized.

Show comment
Hide comment
@krytarowski

This comment has been minimized.

Show comment
Hide comment
@krytarowski

krytarowski Mar 6, 2018

Ping? I think I will add a ptrace wrapper for C and C++ programs.

krytarowski commented Mar 6, 2018

Ping? I think I will add a ptrace wrapper for C and C++ programs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment