Coder Social home page Coder Social logo

Comments (2)

hnes avatar hnes commented on July 24, 2024

Hi @willmafh ;-)

Signals can interrupt processes [see signal(BA_OS)]. Functions called during signal handling have no unusual restrictions on their use of registers. Moreover, if a signal handling function returns, the process resumes its original execution path with registers restored to their original values. Thus, programs and compilers may freely use all registers without the danger of signal handlers changing their values.

-- abi386-4.pdf

So it would be fine as long as we comply with the constraint described in the "Stack Pointer - Miscellaneous - Proof of Correctness" part of README.md:

The stack pointer should always points to the end of the latest allocated stack frame.

P.S.

Here is also a detailed description about the execution of signal handlers:

https://stackoverflow.com/questions/6949025/how-are-asynchronous-signal-handlers-executed-on-linux

from libaco.

hnes avatar hnes commented on July 24, 2024

I also found the description about the execution of signal handler in the man2 page of sigreturn is wonderful:

If the Linux kernel determines that an unblocked signal is pending
for a process, then, at the next transition back to user mode in that
process (e.g., upon return from a system call or when the process is
rescheduled onto the CPU), it creates a new frame on the user-space
stack where it saves various pieces of process context (processor
status word, registers, signal mask, and signal stack settings).

The kernel also arranges that, during the transition back to user
mode, the signal handler is called, and that, upon return from the
handler, control passes to a piece of user-space code commonly called
the "signal trampoline". The signal trampoline code in turn calls
sigreturn().

This sigreturn() call undoes everything that was done—changing the
process's signal mask, switching signal stacks (see
sigaltstack(2))—in order to invoke the signal handler. Using the
information that was earlier saved on the user-space stack
sigreturn() restores the process's signal mask, switches stacks, and
restores the process's context (processor flags and registers,
including the stack pointer and instruction pointer), so that the
process resumes execution at the point where it was interrupted by
the signal.

You also could choose to use gdb to see how signal handler is executing during the call of acosw (here is a demo may be helpful). Happy hacking :-)

from libaco.

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.