You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The text was updated successfully, but these errors were encountered:
hnes
changed the title
直接通过esp取to_co地址会有问题吧???
Question: Would there be some problem if one signal handler is triggered during the call of acosw?
Nov 30, 2018
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.
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 :-)
libaco/acosw.S
Line 65 in c941da6
按照我的理解,这一行之前的: lea ecx,[esp+0x4] // esp, 通过将栈顶指针暂时保存在ecx中是作为一个定点的作用吧,因为前面注释里已经说了,signal可能改变栈顶指针esp的值,那这一行又用esp本身地址+8的方式取得to_co的地址,那万一在这之前esp的值由于signal改变了,那此时ecx里保存的值就不是to_co的地址了吧,不知道我这样配合你上面的注释理解得对不对。探讨一下...
The text was updated successfully, but these errors were encountered: