The basic problem here is that mutable objects inherently have identity. This means that if 2 different functions mutate the same value, that is observable behavior. Other languages get around this in various ways.
C crashes (or causes nasal deamons) if a stack allocated object outlives it’s lifetime
Rust requires that no to functions have mutable references
Java doesn’t have any values on the stack.
Julia takes a middle ground and will put things on the stack if they aren’t mutable (because then the compiler can duplicate/remove the objects as it sees fit), and is also sometimes able to SROA away mutables if the compiler can prove that no one external can observe that the object exists.