4 ms·
How can the thread free its own stack before calling exit? Doesn't it need a stack to call exit safely?
by 0x0 11y ago
How can the thread free its own stack before calling exit? Doesn't it need a stack to call exit safely?
- to3m 11y agoIn general yes, but the code in this case appears to be supplying its own version of exit, that just does a SYSCALL instruction. The SYSCALL instruction doesn't need a stack.
- 0x0 11y agoIs there no risk of an interrupt or a signal happening in between un-mmap'ing and calling exit, that would cause stack pushes?
- Amanieu 11y agoThat is a risk, which is why you need to block all signals using the sigprocmask syscall before unmapping your stack.
- geofft 11y agoOr you just don't have signal-handling functions. Signals only touch the stack if you handle them via functions. The default signal dispositions all either kill the process or do nothing, so they don't touch the stack.
- MarkSweep 11y agoIt is calling the exit syscall directly using the syscall instruction, which does not push anything onto the stack.