Is it possible for one thread to corrupt the stack of another thread by directly modifying the stack address ? How are thread local variables implemented to provide access safety ?
But the child threads stack is different from main thread.
Child Threads' statck consists of the VMA got from mmap. And the it's protected by mprotect(NONE) when segmentfault
main thread's stack is protected by kernel when segmentfault.
Nope, all threads share a common heap, however, each thread has a private stack, and a red zone is appended for each stack
Since each thread has individual stack space, it is not possible to modify another thread's stack variable. Each stack is protected by a boundary and it also stores the start address, current stack pointer and few other information-variables location at the edge. which protects the another thread's stackoverflow modifying stack variables.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.