In the case of segmentation fault, SIGSEGV (11) signal is generated. Generally, a segmentation fault occurs when the program tries to access the memory to which it doesn’t have access to.
Below, I have mentioned some scenarios where SIGSEGV signal is generated.
- When trying to de-referencing a NULL pointer.
- Trying to access memory which is already de-allocated (trying to use dangling pointers).
- Using uninitialized pointer(wild pointer).
- Trying to access memory that the program doesn’t own (eg. trying to access an array element out of array bounds).
In case of a BUS error, SIGBUS (10) signal is generated. The Bus error issue occurs when a program tries to access an invalid memory or unaligned memory. The bus error comes rarely as compared to the segmentation fault.