contributed by < asd617140123 >
$ gcc --version
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 16
On-line CPU(s) list: 0-15
Thread(s) per core: 1
Core(s) per socket: 16
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 85
Model name: Intel(R) Xeon(R) Gold 5218 CPU @ 2.30GHz
Stepping: 7
CPU MHz: 2294.608
BogoMIPS: 4589.21
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 1024K
L3 cache: 22528K
NUMA node0 CPU(s): 0-15
作業要求
struct list_head *q_new()
{
struct list_head* node = malloc(sizeof(struct list_head));
if (node) {
INIT_LIST_HEAD(node);
return node;
}
return NULL;
}
cmd> free
--h - 0x606000000040
ERROR: Attempted to free unallocated block. Address = 0x606000000168
ERROR: Attempted to free unallocated or corrupted block. Address = 0x606000000168
ASAN:DEADLYSIGNAL
=================================================================
==6207==ERROR: AddressSanitizer: SEGV on unknown address 0x6060deadc057 (pc 0x559d2f6aaac8 bp 0x7ffe34bc6b20 sp 0x7ffe34bc6b00 T0)
==6207==The signal is caused by a READ memory access.
#0 0x559d2f6aaac7 in test_free /home/ericw/lab0-c/harness.c:188
#1 0x559d2f6aaf06 in q_free /home/ericw/lab0-c/queue.c:39
#2 0x559d2f6a4c7c in do_free /home/ericw/lab0-c/qtest.c:94
#3 0x559d2f6a868c in interpret_cmda /home/ericw/lab0-c/console.c:185
#4 0x559d2f6a8fe4 in interpret_cmd /home/ericw/lab0-c/console.c:208
#5 0x559d2f6aa700 in run_console /home/ericw/lab0-c/console.c:649
#6 0x559d2f6a74ce in main /home/ericw/lab0-c/qtest.c:962
#7 0x7fa9508f3bf6 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21bf6)
#8 0x559d2f6a4479 in _start (/home/ericw/lab0-c/qtest+0x8479)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/ericw/lab0-c/harness.c:188 in test_free