everest% cc -g malloc3.c everest% everest% a.out Everything is fine up to now, or is it? Calling calloc()... Bus error (core dumped) everest% everest% dbx a.out dbx version 6.2 Mar 9 1996 15:23:28 Core from signal SIGBUS: Bus error (dbx) (dbx) where > 0 __malloc(0x88, 0xd9d0000, 0x14, 0x0, 0x0, 0x0, 0x0, 0x0) ["/xlv23/patches/2086/work/irix/lib/libc/libc_64_M4/gen/malloc.c":284, 0xd9d10ac] 1 _malloc(0x10012048, 0xd9d0000, 0x14, 0x0, 0x0, 0x10013090, 0x0, 0x0) ["/xlv23/patches/2086/work/irix/lib/libc/libc_64_M4/gen/malloc.c":186, 0xd9d0ea8] 2 _calloc(0x0, 0xd9d0000, 0x14, 0x0, 0x0, 0x10013090, 0x0, 0x0) ["/xlv23/patches/2086/work/irix/lib/libc/libc_64_M4/gen/calloc.c":40, 0xd9c99b8] 3 main() ["/home/faculty6/chang/course/cs202/ptr1/malloc3.c":37, 0x10000f4c] 4 __start() ["/vince/6.2-mar09/work/irix/lib/libc/libc_64_M4/csu/crt1text.s":166, 0x10000e28] (dbx) (dbx) list main 12 main() { 13 double *ptr1, *ptr2, *ptr3 ; 14 int i ; 15 16 17 /* Get memory for an array using malloc */ 18 19 ptr1 = (double *) malloc(TOP*sizeof(double)) ; 20 if (ptr1 == NULL) { 21 fprintf(stderr, "malloc() failed!\n") ; (dbx) list 22 exit(1) ; 23 } 24 25 26 /* Initialize array using array notation */ 27 28 for (i = 0 ; i <= TOP ; i++) { /* BIG MISTAKE */ 29 ptr1[i] = i*i ; 30 } 31 (dbx) list 32 printf("Everything is fine up to now, or is it?\n") ; 33 34 /* Get memory for an array using calloc */ 35 36 printf("Calling calloc()...\n") ; 37 ptr2 = (double *) calloc(TOP, sizeof(double)) ; 38 printf("... return from calloc().\n") ; 39 40 if (ptr2 == NULL) { 41 fprintf(stderr, "calloc() failed!\n") ; (dbx) (dbx) quit everest%