Will overstepping of array indices beyond an array size always result in a Segmentation Fault on a reliable true POSIX system like GNU/Linux?
I think no, if the accessed location still lies in the same page, but want to be sure.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, it will not necessarily. Segmentation Violations
SIGSEGVis handled by the Kernel and will only be invoked on an invalid memory access.Arrays are compile-time constructs as is POSIX. Segmentation Violation on the other hand is a run time error indicating that you tried to do something with a piece of virtual memory that you are either not allowed (read/write/execute) or that has not been mapped (the memory controller does not know what physical resource is supposed to back it). At that point the kernel will send your process a signal
SiGSEGVand the default behavior is to exit, though that can be overridden.You will even often see C code like this, which instructs the compiler to access the memory behind the struct as a variable size array:
Only because an array is not defined beyond a certain index, it does not necessarily mean that there is no valid memory following it.