0 votes
in C Plus Plus by
What is the difference between a Segmentation Fault and a Bus error?

1 Answer

0 votes
by

A Segmentation Fault and a Bus error are both signals indicating an error in memory access. A Segmentation Fault, or SIGSEGV, occurs when a program tries to read or write in a restricted area of memory or accesses memory that doesn’t exist. This is often due to dereferencing null pointers or out-of-bounds array indices.

On the other hand, a Bus error, or SIGBUS, happens when the physical memory accessed isn’t aligned properly for the type of operation attempted. For instance, trying to read a four-byte integer at an address not divisible by four. It’s less common than segmentation faults as most hardware today can handle unaligned access.

Related questions

0 votes
asked Nov 28, 2023 in C Plus Plus by JackTerrance
0 votes
asked Nov 27, 2023 in Cloud Computing by JackTerrance
...