/* * imaVax -- pretend to be a vax and access the null pointer, * to test the "thud" algorithm. * * Copyright (C) 2004 David Collier-Brown * * This program is free software; you can redistribute it and/or modify * it under the terms of your choice of the GNU Lesser (Library) General * Public License or the Sun Common Development and Distribution License . */ #include int main(int argc, char *argv[]) { char *p = NULL, c = '?'; char *ProgName = argv[0]; if (argc != 1) { printf("imaVax -- dereference 0 and drop core.\n"); (void) exit(1); } (void) sleep(5); (void) fprintf(stderr, "%s: starting imaVax.\n", ProgName); (void) fprintf(stderr, "%s: dereferencing 0.\n", ProgName); (void) fflush(stderr); c = *p; (void) fprintf(stderr, "%s: survived dereferencing 0, " "c = %#x (\"%c\")\n", ProgName, c, c == 0? ' ': c); (void) fprintf(stderr, "%s: assigning to *0\n", ProgName); (void) fflush(stderr); *p = 'x'; (void) fprintf(stderr, "%s: survived assigning to *0, " "c = %#x (\"%c\")\n", ProgName, c, c == 0? ' ': c); (void) fflush(stderr); return 0; }