A stack frame is the memory record created for one function call. It holds the function’s call state, arguments, return information, and local variables, except data allocated on the heap. section 6.3.1
Function calls create frames in Last In, First Out order. The stack pointer tracks the current frame: it moves as calls add frames and moves back when functions return. While an inner function runs, the caller’s frame is effectively frozen. section 6.3.1
A function call
Calling is_strong("justok") creates a frame for is_strong, including its password argument and return information. When the function returns whether the password is longer than five characters, that frame is removed and execution continues in the caller. section 6.3.1
Keep these differences from the dinner-plate analogy in mind:
- The stack contains both frames and data. section 6.3.1
- Programs can access multiple stack elements, not only the newest one. section 6.3.1
- Frames can have different sizes rather than sharing one standard size. section 6.3.1
fn is_strong(password: String) -> bool {
password.len() > 5
}
Use the function definition and its call to visualize a frame being created for a password-checking operation. section 6.3.1
During exception handling, the call stack is traversed in reverse through its frames. This process, called stack unwinding, invokes a personality function for each frame to determine whether it can handle the exception. section 11.4.1


