Skip to content

Commit 526d79e

Browse files
committed
Merge pull request #21030 from steveklabnik/gh20071
Remove segmented stack info from the FFI chapter of the book. Reviewed-by: nikomatsakis
2 parents fdad8d5 + 9174e4c commit 526d79e

File tree

1 file changed

+0
-23
lines changed

1 file changed

+0
-23
lines changed

src/doc/trpl/ffi.md

-23
Original file line numberDiff line numberDiff line change
@@ -164,29 +164,6 @@ pub fn uncompress(src: &[u8]) -> Option<Vec<u8>> {
164164
For reference, the examples used here are also available as an [library on
165165
GitHub](https://github.com/thestinger/rust-snappy).
166166

167-
# Stack management
168-
169-
Rust threads by default run on a *large stack*. This is actually implemented as a
170-
reserving a large segment of the address space and then lazily mapping in pages
171-
as they are needed. When calling an external C function, the code is invoked on
172-
the same stack as the rust stack. This means that there is no extra
173-
stack-switching mechanism in place because it is assumed that the large stack
174-
for the rust thread is plenty for the C function to have.
175-
176-
A planned future improvement (not yet implemented at the time of this writing)
177-
is to have a guard page at the end of every rust stack. No rust function will
178-
hit this guard page (due to Rust's usage of LLVM's `__morestack`). The intention
179-
for this unmapped page is to prevent infinite recursion in C from overflowing
180-
onto other rust stacks. If the guard page is hit, then the process will be
181-
terminated with a message saying that the guard page was hit.
182-
183-
For normal external function usage, this all means that there shouldn't be any
184-
need for any extra effort on a user's perspective. The C stack naturally
185-
interleaves with the rust stack, and it's "large enough" for both to
186-
interoperate. If, however, it is determined that a larger stack is necessary,
187-
there are appropriate functions in the thread spawning API to control the size of
188-
the stack of the thread which is spawned.
189-
190167
# Destructors
191168

192169
Foreign libraries often hand off ownership of resources to the calling code.

0 commit comments

Comments
 (0)