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.
In 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.
In below I have mentioned some scenarios where SIGBUS signal is generated.
Answer:
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.
In below I have mentioned some scenarios where SIGSEGV signal is generated.
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.
In below I have mentioned some scenarios where SIGBUS signal is generated.
- Non-existent address.
- Unaligned access.
- Paging errors
need an explanation for this answer? contact us directly to get an explanation for this answer