Bus error vs Segmentation fault

前端 未结 7 772
梦毁少年i
梦毁少年i 2020-12-24 01:19

Difference between a bus error and a segmentation fault? Can it happen that a program gives a seg fault and stops for the first time and for the second time it may give a bu

7条回答
  •  -上瘾入骨i
    2020-12-24 02:05

    On most architectures I've used, the distinction is that:

    • a SEGV is caused when you access memory you're not meant to (e.g., outside of your address space).
    • a SIGBUS is caused due to alignment issues with the CPU (e.g., trying to read a long from an address which isn't a multiple of 4).

提交回复
热议问题