Your instructor runs the following command at the beginning of each class: script shell-logs/`date | sed "s/ /_/g"` The resulting log is taken and edited to remove escape characters, which may introduce some errors. The result should be a fairly faithful reproduction of the shell output from class ------------------------------------------------------ Script started on Wed 22 Nov 2006 02:43:42 PM PST bash-3.1$ cd lectures/lecture20-extras/hw4 bash-3.1$ ls allocreclist.c allocreclist.o heap.c heap.o heaptest.c Makefile allocreclist.h #heap.c# heap.h heaptest heaptest.o bash-3.1$ less Makefile # You can reuse this Makefile more easily than Makefile.basic. # You just have to fix the target name, the list of objects, # And fix the dependencies at the bottom. CC = gcc CFLAGS = -g -Wall TARGET = heaptest OBJECTS = heaptest.o heap.o allocreclist.o $(TARGET): $(OBJECTS) $(CC) $(CFLAGS) -o $@ $(OBJECTS) clean: rm -f $(TARGET) $(OBJECTS) heaptest.o: heaptest.c heap.h $(CC) $(CFLAGS) -o $@ -c $< heap.o: heap.c heap.h allocreclist.h $(CC) $(CFLAGS) -o $@ -c $< allocreclist.o: allocreclist.c allocreclist.h $(CC) $(CFLAGS) -o $@ -c $< bash-3.1$ ls allocreclist.c allocreclist.o heap.c heap.o heaptest.c Makefile allocreclist.h #heap.c# heap.h heaptest heaptest.o bash-3.1$ gdb heaptest GNU gdb Red Hat Linux (6.3.0.0-1.134.fc5rh) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". (gdb) quit bash-3.1$ cd .. bash-3.1$ cd hw5 bash-3.1$ ls bug4 bug4.cpp core.10050 Pointec Problem2 bash-3.1$ gdb bug4 GNU gdb Red Hat Linux (6.3.0.0-1.134.fc5rh) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". (gdb) run Starting program: /homes/iws/rcdavis/lectures/lecture20-extras/hw5/bug4 Reading symbols from shared object read from target memory...done. Loaded system supplied DSO at 0xffffe000 *** glibc detected *** /homes/iws/rcdavis/lectures/lecture20-extras/hw5/bug4: double free or corruption (fasttop): 0x0804a018 *** ======= Backtrace: ========= /lib/libc.so.6[0x43247a68] /lib/libc.so.6(__libc_free+0x78)[0x4324af6f] /usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0x43dc96c1] /homes/iws/rcdavis/lectures/lecture20-extras/hw5/bug4(__gxx_personality_v0+0x1c3)[0x80485d7] /homes/iws/rcdavis/lectures/lecture20-extras/hw5/bug4(__gxx_personality_v0+0x153)[0x8048567] /lib/libc.so.6(__libc_start_main+0xdc)[0x431f94e4] /homes/iws/rcdavis/lectures/lecture20-extras/hw5/bug4(__gxx_personality_v0+0x5d)[0x8048471] ======= Memory map: ======== 08048000-08049000 r-xp 00000000 00:2e 86409017 /homes/iws/rcdavis/lectures/lecture20-extras/hw5/bug4 08049000-0804a000 rw-p 00000000 00:2e 86409017 /homes/iws/rcdavis/lectures/lecture20-extras/hw5/bug4 0804a000-0806b000 rw-p 0804a000 00:00 0 [heap] 431c7000-431e0000 r-xp 00000000 08:02 72 /lib/ld-2.4.so 431e0000-431e1000 r--p 00018000 08:02 72 /lib/ld-2.4.so 431e1000-431e2000 rw-p 00019000 08:02 72 /lib/ld-2.4.so 431e4000-43311000 r-xp 00000000 08:02 1110 /lib/libc-2.4.so 43311000-43313000 r--p 0012d000 08:02 1110 /lib/libc-2.4.so 43313000-43314000 rw-p 0012f000 08:02 1110 /lib/libc-2.4.so 43314000-43317000 rw-p 43314000 00:00 0 43319000-4333c000 r-xp 00000000 08:02 1118 /lib/libm-2.4.so 4333c000-4333d000 r--p 00022000 08:02 1118 /lib/libm-2.4.so 4333d000-4333e000 rw-p 00023000 08:02 1118 /lib/libm-2.4.so 43bf8000-43c03000 r-xp 00000000 08:02 1145 /lib/libgcc_s-4.1.1-20060525.so.1 43c03000-43c04000 rw-p 0000a000 08:02 1145 /lib/libgcc_s-4.1.1-20060525.so.1 43d14000-43df6000 r-xp 00000000 08:05 1477161 /usr/lib/libstdc++.so.6.0.8 43df6000-43dfa000 r--p 000e1000 08:05 1477161 /usr/lib/libstdc++.so.6.0.8 43dfa000-43dfb000 rw-p 000e5000 08:05 1477161 /usr/lib/libstdc++.so.6.0.8 43dfb000-43e01000 rw-p 43dfb000 00:00 0 b7e00000-b7e21000 rw-p b7e00000 00:00 0 b7e21000-b7f00000 ---p b7e21000 00:00 0 b7f2c000-b7f2e000 rw-p b7f2c000 00:00 0 b7f3a000-b7f3b000 rw-p b7f3a000 00:00 0 bfa25000-bfa3b000 rw-p bfa25000 00:00 0 [stack] ffffe000-fffff000 ---p 00000000 00:00 0 [vdso] Program received signal SIGABRT, Aborted. 0xffffe410 in __kernel_vsyscall () (gdb) where #0 0xffffe410 in __kernel_vsyscall () #1 0x4320bee9 in raise () from /lib/libc.so.6 #2 0x4320d4f1 in abort () from /lib/libc.so.6 #3 0x4324053b in __libc_message () from /lib/libc.so.6 #4 0x43247a68 in _int_free () from /lib/libc.so.6 #5 0x4324af6f in free () from /lib/libc.so.6 #6 0x43dc96c1 in operator delete () from /usr/lib/libstdc++.so.6 #7 0x080485d7 in ~A (this=0xbfa38484) at bug4.cpp:5 #8 0x08048567 in main () at bug4.cpp:19 (gdb) l 19 return extract(a1); 20 } (gdb) up #1 0x4320bee9 in raise () from /lib/libc.so.6 (gdb) up #2 0x4320d4f1 in abort () from /lib/libc.so.6 (gdb) #3 0x4324053b in __libc_message () from /lib/libc.so.6 (gdb) #4 0x43247a68 in _int_free () from /lib/libc.so.6 (gdb) #5 0x4324af6f in free () from /lib/libc.so.6 (gdb) #6 0x43dc96c1 in operator delete () from /usr/lib/libstdc++.so.6 (gdb) #7 0x080485d7 in ~A (this=0xbfa38484) at bug4.cpp:5 5 ~A() { delete p; } (gdb) l 1 class A { 2 public: 3 int *p; 4 A(int x=0) { p = new int(x); } 5 ~A() { delete p; } 6 }; 7 8 int extract(A a) 9 { 10 return *(a.p); (gdb) quit The program is running. Exit anyway? (y or n) y bash-3.1$ ulimit -c 16000 bash-3.1$ ./bug4 *** glibc detected *** ./bug4: double free or corruption (fasttop): 0x0804a018 *** ======= Backtrace: ========= /lib/libc.so.6[0x43247a68] /lib/libc.so.6(__libc_free+0x78)[0x4324af6f] /usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0x43dc96c1] ./bug4(__gxx_personality_v0+0x1c3)[0x80485d7] ./bug4(__gxx_personality_v0+0x153)[0x8048567] /lib/libc.so.6(__libc_start_main+0xdc)[0x431f94e4] ./bug4(__gxx_personality_v0+0x5d)[0x8048471] ======= Memory map: ======== 08048000-08049000 r-xp 00000000 00:2e 86409017 /homes/iws/rcdavis/lectures/lecture20-extras/hw5/bug4 08049000-0804a000 rw-p 00000000 00:2e 86409017 /homes/iws/rcdavis/lectures/lecture20-extras/hw5/bug4 0804a000-0806b000 rw-p 0804a000 00:00 0 [heap] 431c7000-431e0000 r-xp 00000000 08:02 72 /lib/ld-2.4.so 431e0000-431e1000 r--p 00018000 08:02 72 /lib/ld-2.4.so 431e1000-431e2000 rw-p 00019000 08:02 72 /lib/ld-2.4.so 431e4000-43311000 r-xp 00000000 08:02 1110 /lib/libc-2.4.so 43311000-43313000 r--p 0012d000 08:02 1110 /lib/libc-2.4.so 43313000-43314000 rw-p 0012f000 08:02 1110 /lib/libc-2.4.so 43314000-43317000 rw-p 43314000 00:00 0 43319000-4333c000 r-xp 00000000 08:02 1118 /lib/libm-2.4.so 4333c000-4333d000 r--p 00022000 08:02 1118 /lib/libm-2.4.so 4333d000-4333e000 rw-p 00023000 08:02 1118 /lib/libm-2.4.so 43bf8000-43c03000 r-xp 00000000 08:02 1145 /lib/libgcc_s-4.1.1-20060525.so.1 43c03000-43c04000 rw-p 0000a000 08:02 1145 /lib/libgcc_s-4.1.1-20060525.so.1 43d14000-43df6000 r-xp 00000000 08:05 1477161 /usr/lib/libstdc++.so.6.0.8 43df6000-43dfa000 r--p 000e1000 08:05 1477161 /usr/lib/libstdc++.so.6.0.8 43dfa000-43dfb000 rw-p 000e5000 08:05 1477161 /usr/lib/libstdc++.so.6.0.8 43dfb000-43e01000 rw-p 43dfb000 00:00 0 b7e00000-b7e21000 rw-p b7e00000 00:00 0 b7e21000-b7f00000 ---p b7e21000 00:00 0 b7f40000-b7f42000 rw-p b7f40000 00:00 0 b7f4e000-b7f4f000 rw-p b7f4e000 00:00 0 bfd39000-bfd4f000 rw-p bfd39000 00:00 0 [stack] ffffe000-fffff000 ---p 00000000 00:00 0 [vdso] Aborted (core dumped) bash-3.1$ ls bug4 bug4.cpp core.10050 core.19889 Pointec Problem2 bash-3.1$ gdb bug4 core.19889 GNU gdb Red Hat Linux (6.3.0.0-1.134.fc5rh) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". Reading symbols from shared object read from target memory...done. Loaded system supplied DSO at 0xffffe000 Core was generated by `./bug4'. Program terminated with signal 6, Aborted. warning: svr4_current_sos: Can't read pathname for load map: Input/output error Reading symbols from /usr/lib/libstdc++.so.6...done. Loaded symbols for /usr/lib/libstdc++.so.6 Reading symbols from /lib/libm.so.6...done. Loaded symbols for /lib/libm.so.6 Reading symbols from /lib/libgcc_s.so.1...done. Loaded symbols for /lib/libgcc_s.so.1 Reading symbols from /lib/libc.so.6...done. Loaded symbols for /lib/libc.so.6 Reading symbols from /lib/ld-linux.so.2...done. Loaded symbols for /lib/ld-linux.so.2 #0 0xffffe410 in __kernel_vsyscall () (gdb) where #0 0xffffe410 in __kernel_vsyscall () #1 0x4320bee9 in raise () from /lib/libc.so.6 #2 0x4320d4f1 in abort () from /lib/libc.so.6 #3 0x4324053b in __libc_message () from /lib/libc.so.6 #4 0x43247a68 in _int_free () from /lib/libc.so.6 #5 0x4324af6f in free () from /lib/libc.so.6 #6 0x43dc96c1 in operator delete () from /usr/lib/libstdc++.so.6 #7 0x080485d7 in ~A (this=0xbfd4bc24) at bug4.cpp:5 #8 0x08048567 in main () at bug4.cpp:19 (gdb) up #1 0x4320bee9 in raise () from /lib/libc.so.6 (gdb) #2 0x4320d4f1 in abort () from /lib/libc.so.6 (gdb) #3 0x4324053b in __libc_message () from /lib/libc.so.6 (gdb) #4 0x43247a68 in _int_free () from /lib/libc.so.6 (gdb) #5 0x4324af6f in free () from /lib/libc.so.6 (gdb) #6 0x43dc96c1 in operator delete () from /usr/lib/libstdc++.so.6 (gdb) #7 0x080485d7 in ~A (this=0xbfd4bc24) at bug4.cpp:5 5 ~A() { delete p; } (gdb) l 1 class A { 2 public: 3 int *p; 4 A(int x=0) { p = new int(x); } 5 ~A() { delete p; } 6 }; 7 8 int extract(A a) 9 { 10 return *(a.p); (gdb) quit bash-3.1$ ls -l total 244 -rwxr-xr-x 1 rcdavis grad_cs 7537 Nov 22 13:07 bug4 -rw-r--r-- 1 rcdavis grad_cs 194 Nov 8 10:18 bug4.cpp -rw------- 1 rcdavis grad_cs 475136 Nov 22 14:00 core.10050 -rw------- 1 rcdavis grad_cs 475136 Nov 22 15:03 core.19889 drwxr-xr-x 2 rcdavis grad_cs 71 Nov 22 13:12 Pointec drwxr-xr-x 2 rcdavis grad_cs 74 Nov 22 13:11 Problem2 bash-3.1$ ulimit -c 0 bash-3.1$ ./bug4 *** glibc detected *** ./bug4: double free or corruption (fasttop): 0x0804a018 *** ======= Backtrace: ========= /lib/libc.so.6[0x43247a68] /lib/libc.so.6(__libc_free+0x78)[0x4324af6f] /usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0x43dc96c1] ./bug4(__gxx_personality_v0+0x1c3)[0x80485d7] ./bug4(__gxx_personality_v0+0x153)[0x8048567] /lib/libc.so.6(__libc_start_main+0xdc)[0x431f94e4] ./bug4(__gxx_personality_v0+0x5d)[0x8048471] ======= Memory map: ======== 08048000-08049000 r-xp 00000000 00:2e 86409017 /homes/iws/rcdavis/lectures/lecture20-extras/hw5/bug4 08049000-0804a000 rw-p 00000000 00:2e 86409017 /homes/iws/rcdavis/lectures/lecture20-extras/hw5/bug4 0804a000-0806b000 rw-p 0804a000 00:00 0 [heap] 431c7000-431e0000 r-xp 00000000 08:02 72 /lib/ld-2.4.so 431e0000-431e1000 r--p 00018000 08:02 72 /lib/ld-2.4.so 431e1000-431e2000 rw-p 00019000 08:02 72 /lib/ld-2.4.so 431e4000-43311000 r-xp 00000000 08:02 1110 /lib/libc-2.4.so 43311000-43313000 r--p 0012d000 08:02 1110 /lib/libc-2.4.so 43313000-43314000 rw-p 0012f000 08:02 1110 /lib/libc-2.4.so 43314000-43317000 rw-p 43314000 00:00 0 43319000-4333c000 r-xp 00000000 08:02 1118 /lib/libm-2.4.so 4333c000-4333d000 r--p 00022000 08:02 1118 /lib/libm-2.4.so 4333d000-4333e000 rw-p 00023000 08:02 1118 /lib/libm-2.4.so 43bf8000-43c03000 r-xp 00000000 08:02 1145 /lib/libgcc_s-4.1.1-20060525.so.1 43c03000-43c04000 rw-p 0000a000 08:02 1145 /lib/libgcc_s-4.1.1-20060525.so.1 43d14000-43df6000 r-xp 00000000 08:05 1477161 /usr/lib/libstdc++.so.6.0.8 43df6000-43dfa000 r--p 000e1000 08:05 1477161 /usr/lib/libstdc++.so.6.0.8 43dfa000-43dfb000 rw-p 000e5000 08:05 1477161 /usr/lib/libstdc++.so.6.0.8 43dfb000-43e01000 rw-p 43dfb000 00:00 0 b7e00000-b7e21000 rw-p b7e00000 00:00 0 b7e21000-b7f00000 ---p b7e21000 00:00 0 b7f2d000-b7f2f000 rw-p b7f2d000 00:00 0 b7f3b000-b7f3c000 rw-p b7f3b000 00:00 0 bf827000-bf83c000 rw-p bf827000 00:00 0 [stack] ffffe000-fffff000 ---p 00000000 00:00 0 [vdso] Aborted bash-3.1$ exit exit Script done on Wed 22 Nov 2006 03:22:19 PM PS