Bus error vs Segmentation fault

前端 未结 7 790
梦毁少年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条回答
  •  一个人的身影
    2020-12-24 01:59

    For instance, a bus error might be caused when your program tries to do something that the hardware bus doesn't support. On SPARCs, for instance, trying to read a multi-byte value (such as an int, 32-bits) from an odd address generated a bus error.

    Segmentation faults happen for instance when you do an access that violate the segmentation rules, i.e. trying to read or write memory that you don't own.

提交回复
热议问题