Refer to this answer https://stackoverflow.com/a/1422774/16238824
Whatever the garbage value is, I guess we can overwrite it (in order to assign a value).
So how does garbage value cause segmentation fault?
Refer to this answer https://stackoverflow.com/a/1422774/16238824
Whatever the garbage value is, I guess we can overwrite it (in order to assign a value).
So how does garbage value cause segmentation fault?
A segmentation fault is triggered by the operating system when you access protected memory that does not belong to your application. Not every operating system offers protected memory, and in fact the "garbage values" and "segmentation fault" are actually byproducts of the same underlying issue; you are triggering undefined behavior. On some implementations, the memory will be initialized to sane default values. On some implementations, the memory will be in whatever state the last process to write to that memory held.