Coder Social home page Coder Social logo

Signal Delivery about dettrace HOT 5 CLOSED

dettrace avatar dettrace commented on May 17, 2024
Signal Delivery

from dettrace.

Comments (5)

gatoWololo avatar gatoWololo commented on May 17, 2024

This issues has been fixed. Signals are now delivered properly.

There is noticeable delay between delivering a signal and the tracee receiving the signal. Consider the program:

#include <signal.h>
#include <stdio.h>

int main(){
  raise(SIGABRT);
  printf("Hello World!\n");
}

Running this program by itself aborts. But under dettrace it completes. We don't really have power to when the signal is delivered so this may be nondeterministic. We discussed a solution by:

  1. Saving the state of the program
  2. Jumping to the signal handler by moving the instruction pointer.

Signals may be ignored if done through ptrace. From man ptrace(2):

Restarting ptrace commands issued in ptrace-stops other than signal-delivery-stop are
not  guaranteed  to inject a signal, even if sig is nonzero.  No error is reported; a
nonzero sig may simply be ignored.  Ptrace users should not try to "create a new sig‐
nal" this way: use tgkill(2) instead.

The  fact  that  signal  injection requests may be ignored when restarting the tracee
after ptrace stops that are not signal-delivery-stops is a cause of  confusion  among
ptrace  users.

So it seems tgkill is the way to go.

from dettrace.

devietti avatar devietti commented on May 17, 2024

Reopening this until we whitelist signal delivery.

Summarizing some Slack discussion here for future reference:

  • Deterministic signal delivery likely requires jumping directly to the signal handler, so we can be sure when the signal is "delivered"
  • Need to jump back to application code once the signal handler is done. How do we figure out when the handler is "done"? Maybe we can munge the signal stack and overwrite the return address appropriately? Also need to ensure that the app context is restored.

from dettrace.

gatoWololo avatar gatoWololo commented on May 17, 2024

As far as your second bullet point. I believe we receive a sigreturn/rt_sigreturn when the handler is done.

from dettrace.

rrnewton avatar rrnewton commented on May 17, 2024

[this came up briefly in the call today]

@devietti - re: "jumping directly to the signal handler", is the idea that signal delivery would be instantaneous? E.g., in a sequentialized set of processes/threads, one thread sending a SIGKILL should resolve immediately before any other code runs.

Instantaneous signal delivery seems really appealing in a sequential scheduler. But, hmm, perhaps that would compromise achieving observable equivalence between a sequential scheduler and one that employs true parallelism...

from dettrace.

devietti avatar devietti commented on May 17, 2024

Closing this thanks to #106, we have this working for SIGALRM.

from dettrace.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.