Seg faults sre usually generated by the OS.
On most hardware the segfault occurs when you try to access a virtual memory address where the OS doesn't know how to map it to a physical address.
Most common is for addresses around 0 when a NULL pointer is deferenced, but you also do so by accessing a virtual memory address outside of those assigned to the stack, the heap or the program's code area (and many others type of memory that a process might allocate).
Virtual memory is given to your process in pages (maybe with a size of 4KB), so if you access outside an array by a little bit you wont usually cause a seg fault. Examples of this could be accessing an array with an index of -1 or that of the number of elements in the array - usually these result in unexpected memory corruption, not a segfault.