the heap, but correct me if there is something wrong.
My question was:
Why the multithreaded process does not StackOverflow?
In this story, I am talking about pthread.
Facts:
1. When a process spawns a thread, its thread shares the same virtual memory address with the main process.
2. Every single thread has its stack.
These facts imply that a single process will have a stack size more than R_LIMIT_STACK.
> Because every single thread has its stack with the same size as the main process
> and the memory owned by the thread is also owned by the main process.
So what happens here?
> mmap is behind this strange limit stack violation.
> When the process spawns a thread with ptread_create, it also maps heap and plugs it to RSP register that is held by the thread.
> So it will not make your program StackOverflow because of spawning thread.
> Stack in the thread is actually heap that is mapped with MAP_STACK.
I could figure it out by using strace.
I did, this is my conclusion in the case above, I could not find the article about that. So I would welcome for any correction.
Обсуждают сегодня