Saturday, 7 July 2018

SIGBUS

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).


  • a SEGV is caused when you access memory you're not meant to (e.g., outside of your address space).
bus_segv.c:
#include 

char array[10];

int main(int argc, char *argv[]) {
    return array[atol(argv[1])];
}
$ ./bus_segv -4129
Segmentation fault: 11

$ ./bus_segv 28639
Bus error: 10
$ ./bus_segv 53215
Bus error: 10



No comments:

Post a Comment