Section 3: Address Sanitizers #

Dates: February 19, 2026 – February 21, 2026

Learning Goals 🎯 #

By the end of this section you will be able to:

  1. Better understand different types of memory access errors (heap use-after-free, heap buffer overflow, memory leak).
  2. Interpret sanitizer messages by identifying the critical portions of the error message.

What are sanitizers? #

The Address Sanitizer (ASan) is a useful tool that detects memory access errors at runtime, helping us identify issues such as memory leaks, accessing invalid memory, etc. You have already seen some of these errors while working on Snake and DMalloc πŸ‘€. In this section, we will look more closely at programs involving different memory errors.

Part 1: Understanding Address Sanitizer Errors #

You and your partner should look at the program for your assigned group along with the corresponding sanitizer error messages and complete the following steps:

  1. Start by looking at the sanitizer message alone before looking at the code.
  2. Highlight and annotate the clues in the sanitizer message that point you towards the bug in the code. Use the following colors:
    • Blue: variables.
    • Yellow: bytes/memory location.
    • Pink: operations.
  3. Think about where in the sanitizer message you can find the answers to the following questions:
    • What is the memory error?
    • Which part of the code is causing the error?
    • Where in memory are these errors occurring?
⚠️ Note About Shadow Bytes: Sanitizer errors will often include debug outputs referencing "shadow bytes" at the bottom of the error message. You can ignore them for this section! You will learn what these are later in the semester, but we include them in this part so you can see what a complete sanitizer error looks like.
Group 1

Code #

#include <stdio.h>
#include <stdlib.h>

void update_and_free(int* obj) {
   *obj = 5;
   free(obj);
}

int main() {
   int* obj = (int*)malloc(sizeof(int));
   update_and_free(obj);
   *obj = 10;
}

Sanitizer Error #

==56266==ERROR: AddressSanitizer: heap-use-after-free on address 0x502000000010 at pc 0xaaaab1970a08 bp 0xffffc52fa0a0 sp 0xffffc52fa090
WRITE of size 4 at 0x502000000010 thread T0
    #0 0xaaaab1970a04 in main /home/cs300-user/section/sec3.c:12
    #1 0xffffa22684c0 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #2 0xffffa2268594 in __libc_start_main_impl ../csu/libc-start.c:360
    #3 0xaaaab197082c in _start (/home/cs300-user/section/sec3+0x82c) (BuildId: 8966c94ad4fc5599c2e07bc49d29bda9f334f1ab)

0x502000000010 is located 0 bytes inside of 4-byte region [0x502000000010,0x502000000014)
freed by thread T0 here:
    #0 0xffffa24e61b4 in free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:52
    #1 0xaaaab1970988 in update_and_free /home/cs300-user/section/sec3.c:6
    #2 0xaaaab19709b0 in main /home/cs300-user/section/sec3.c:11
    #3 0xffffa22684c0 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #4 0xffffa2268594 in __libc_start_main_impl ../csu/libc-start.c:360
    #5 0xaaaab197082c in _start (/home/cs300-user/section/sec3+0x82c) (BuildId: 8966c94ad4fc5599c2e07bc49d29bda9f334f1ab)

previously allocated by thread T0 here:
    #0 0xffffa24e76d0 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0xaaaab19709a4 in main /home/cs300-user/section/sec3.c:10
    #2 0xffffa22684c0 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #3 0xffffa2268594 in __libc_start_main_impl ../csu/libc-start.c:360
    #4 0xaaaab197082c in _start (/home/cs300-user/section/sec3+0x82c) (BuildId: 8966c94ad4fc5599c2e07bc49d29bda9f334f1ab)

SUMMARY: AddressSanitizer: heap-use-after-free /home/cs300-user/section/sec3.c:12 in main
Shadow bytes around the buggy address:
  0x501ffffffd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501ffffffe00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501ffffffe80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501fffffff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501fffffff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x502000000000: fa fa[fd]fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000100: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000180: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
Group 2

Code #

#include <stdio.h>
#include <stdlib.h>

int main() {
   char* charArr = (char*)malloc(8);
   for(int i=0; i<=8; i++) {
       charArr[i] = 'a';
   }
   free(charArr);
}

Sanitizer Error #

==62190==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x502000000018 at pc 0xaaaab63b098c bp 0xffffe9b1c710 sp 0xffffe9b1c700
WRITE of size 1 at 0x502000000018 thread T0
    #0 0xaaaab63b0988 in main /home/cs300-user/section/sec3.c:7
    #1 0xffff83e684c0 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #2 0xffff83e68594 in __libc_start_main_impl ../csu/libc-start.c:360
    #3 0xaaaab63b082c in _start (/home/cs300-user/section/sec3+0x82c) (BuildId: 08ede02cb64352b72ed46cd65023df8c6e2aec7a)

0x502000000018 is located 0 bytes after 8-byte region [0x502000000010,0x502000000018)
allocated by thread T0 here:
    #0 0xffff840e76d0 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0xaaaab63b0924 in main /home/cs300-user/section/sec3.c:5
    #2 0xffff83e684c0 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #3 0xffff83e68594 in __libc_start_main_impl ../csu/libc-start.c:360
    #4 0xaaaab63b082c in _start (/home/cs300-user/section/sec3+0x82c) (BuildId: 08ede02cb64352b72ed46cd65023df8c6e2aec7a)

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/cs300-user/section/sec3.c:7 in main
Shadow bytes around the buggy address:
  0x501ffffffd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501ffffffe00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501ffffffe80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501fffffff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501fffffff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x502000000000: fa fa 00[fa]fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000100: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000180: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
Group 3

Code #

#include <stdio.h>
#include <stdlib.h>

int main() {
   char* charArr = (char*)malloc(8);
   for(int i=0; i<8; i++) {
       charArr[i] = 'a';
   }
}

Sanitizer Error #

==63516==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0xffff8c6e76d0 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0xaaaad62608e4 in main /home/cs300-user/section/sec3.c:5
    #2 0xffff8c4684c0 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #3 0xffff8c468594 in __libc_start_main_impl ../csu/libc-start.c:360
    #4 0xaaaad62607ec in _start (/home/cs300-user/section/sec3+0x7ec) (BuildId: e081b4f73b3184c93c9d871783334c5d7831ab83)

SUMMARY: AddressSanitizer: 8 byte(s) leaked in 1 allocation(s).

Part 2: Trickier Program #

Now that you’re more familiar with sanitizer errors, look at the following errors with your team and identify the corresponding issues in the program below.

Code #

#include <stdio.h>
#include <stdlib.h>

int main()
{
   int* alloc = (int*)malloc(sizeof(int) * 2);
   int* array = (int*)malloc(sizeof(int) * 4);
   array = alloc;

   int *track;
   for (int i = 0; i<2; i++)
   {
       printf("Index %i = %i\n", i, array[i + 1]);
       track = &array[i];
   }

   free(alloc);
   printf("%i\n", *track);
   free(array);
}

Sanitizer Error 1 #

=================================================================
==98868==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x502000000018 at pc 0xaaaaae2c0b30 bp 0xfffffe6d05b0 sp 0xfffffe6d05a0
READ of size 4 at 0x502000000018 thread T0
    #0 0xaaaaae2c0b2c in main /home/cs300-user/sandbox/section_test.c:13
    #1 0xffff930684c0 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #2 0xffff93068594 in __libc_start_main_impl ../csu/libc-start.c:360
    #3 0xaaaaae2c09ac in _start (/home/cs300-user/sandbox/section_test+0x9ac) (BuildId: 09287a85694d8dd1c395c60e5668adb445c0a553)

0x502000000018 is located 0 bytes after 8-byte region [0x502000000010,0x502000000018)
allocated by thread T0 here:
    #0 0xffff932e76d0 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0xaaaaae2c0aa4 in main /home/cs300-user/sandbox/section_test.c:6
    #2 0xffff930684c0 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #3 0xffff93068594 in __libc_start_main_impl ../csu/libc-start.c:360
    #4 0xaaaaae2c09ac in _start (/home/cs300-user/sandbox/section_test+0x9ac) (BuildId: 09287a85694d8dd1c395c60e5668adb445c0a553)

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/cs300-user/sandbox/section_test.c:13 in main
Shadow bytes around the buggy address:
  0x501ffffffd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501ffffffe00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501ffffffe80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501fffffff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501fffffff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x502000000000: fa fa 00[fa]fa fa 00 00 fa fa fa fa fa fa fa fa
  0x502000000080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000100: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000180: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==98868==ABORTING

Sanitizer Error 2 #

=================================================================
==82202==ERROR: AddressSanitizer: heap-use-after-free on address 0x502000000014 at pc 0xaaaadf430bcc bp 0xffffe5657930 sp 0xffffe5657920
READ of size 4 at 0x502000000014 thread T0
    #0 0xaaaadf430bc8 in main /home/cs300-user/sandbox/section_test.c:18
    #1 0xffff830684c0 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #2 0xffff83068594 in __libc_start_main_impl ../csu/libc-start.c:360
    #3 0xaaaadf4309ac in _start (/home/cs300-user/sandbox/section_test+0x9ac) (BuildId: 56c7227bc9f0d36464fb33cfb51a84c55c85144f)

0x502000000014 is located 4 bytes inside of 8-byte region [0x502000000010,0x502000000018)
freed by thread T0 here:
    #0 0xffff832e61b4 in free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:52
    #1 0xaaaadf430b74 in main /home/cs300-user/sandbox/section_test.c:17
    #2 0xffff830684c0 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #3 0xffff83068594 in __libc_start_main_impl ../csu/libc-start.c:360
    #4 0xaaaadf4309ac in _start (/home/cs300-user/sandbox/section_test+0x9ac) (BuildId: 56c7227bc9f0d36464fb33cfb51a84c55c85144f)

previously allocated by thread T0 here:
    #0 0xffff832e76d0 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0xaaaadf430aa4 in main /home/cs300-user/sandbox/section_test.c:6
    #2 0xffff830684c0 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #3 0xffff83068594 in __libc_start_main_impl ../csu/libc-start.c:360
    #4 0xaaaadf4309ac in _start (/home/cs300-user/sandbox/section_test+0x9ac) (BuildId: 56c7227bc9f0d36464fb33cfb51a84c55c85144f)

SUMMARY: AddressSanitizer: heap-use-after-free /home/cs300-user/sandbox/section_test.c:18 in main
Shadow bytes around the buggy address:
  0x501ffffffd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501ffffffe00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501ffffffe80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501fffffff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501fffffff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x502000000000: fa fa[fd]fa fa fa 00 00 fa fa fa fa fa fa fa fa
  0x502000000080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000100: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000180: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==82202==ABORTING

Sanitizer Error 3 #

=================================================================
==82714==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0xffffb86e76d0 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0xaaaae0e40ab0 in main /home/cs300-user/sandbox/section_test.c:7
    #2 0xffffb84684c0 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #3 0xffffb8468594 in __libc_start_main_impl ../csu/libc-start.c:360
    #4 0xaaaae0e409ac in _start (/home/cs300-user/sandbox/section_test+0x9ac) (BuildId: c2455e4b3948868026c8f45baa7822c7d20a8d42)

SUMMARY: AddressSanitizer: 16 byte(s) leaked in 1 allocation(s).

BONUS! #

Here’s one more program for us to practice with as a class!

Hint: Take a look at the memory addresses below to better understand the code!

Memory Addresses #

num’s address: 0x502000000010 array1’s address: 0x502000000030

Code #

#include <stdio.h>
#include <stdlib.h>

int main() {
   int* num = (int*)malloc(sizeof(int));
   int* array1 = (int*)malloc(2 * sizeof(int));
   long* array2 = (long*) array1;

   *num = 42;
   free(num);

   array1[0] = 999;
   array1[1] = 888;
   array2[0] = 300;
   array2[1] = 600;

   *(array1 - 8) = 100;
}

Sanitizer Error 1 #

==72515==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x502000000038 at pc 0xaaaab2350b04 bp 0xffffd3de2bb0 sp 0xffffd3de2ba0
WRITE of size 8 at 0x502000000038 thread T0
    #0 0xaaaab2350b00 in main /home/cs300-user/section/sec3.c:15
    #1 0xffffb7e684c0 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #2 0xffffb7e68594 in __libc_start_main_impl ../csu/libc-start.c:360
    #3 0xaaaab235086c in _start (/home/cs300-user/section/sec3+0x86c) (BuildId: 6c252bedf4510da44e4d65985c3851ef0c8d5b7c)

0x502000000038 is located 0 bytes after 8-byte region [0x502000000030,0x502000000038)
allocated by thread T0 here:
    #0 0xffffb80e76d0 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0xaaaab2350970 in main /home/cs300-user/section/sec3.c:6
    #2 0xffffb7e684c0 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #3 0xffffb7e68594 in __libc_start_main_impl ../csu/libc-start.c:360
    #4 0xaaaab235086c in _start (/home/cs300-user/section/sec3+0x86c) (BuildId: 6c252bedf4510da44e4d65985c3851ef0c8d5b7c)

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/cs300-user/section/sec3.c:15 in main
Shadow bytes around the buggy address:
  0x501ffffffd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501ffffffe00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501ffffffe80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501fffffff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501fffffff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x502000000000: fa fa fd fa fa fa 00[fa]fa fa fa fa fa fa fa fa
  0x502000000080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000100: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000180: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb

Sanitizer Error 2 #

==73252==ERROR: AddressSanitizer: heap-use-after-free on address 0x502000000010 at pc 0xaaaadab70b34 bp 0xfffffb21f530 sp 0xfffffb21f520
WRITE of size 4 at 0x502000000010 thread T0
    #0 0xaaaadab70b30 in main /home/cs300-user/section/sec3.c:17
    #1 0xffffa60684c0 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #2 0xffffa6068594 in __libc_start_main_impl ../csu/libc-start.c:360
    #3 0xaaaadab7086c in _start (/home/cs300-user/section/sec3+0x86c) (BuildId: a9529991362723cd40c70a6774ae1ecb9b8efe27)

0x502000000010 is located 0 bytes inside of 4-byte region [0x502000000010,0x502000000014)
freed by thread T0 here:
    #0 0xffffa62e61b4 in free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:52
    #1 0xaaaadab709e4 in main /home/cs300-user/section/sec3.c:10
    #2 0xffffa60684c0 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #3 0xffffa6068594 in __libc_start_main_impl ../csu/libc-start.c:360
    #4 0xaaaadab7086c in _start (/home/cs300-user/section/sec3+0x86c) (BuildId: a9529991362723cd40c70a6774ae1ecb9b8efe27)

previously allocated by thread T0 here:
    #0 0xffffa62e76d0 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0xaaaadab70964 in main /home/cs300-user/section/sec3.c:5
    #2 0xffffa60684c0 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #3 0xffffa6068594 in __libc_start_main_impl ../csu/libc-start.c:360
    #4 0xaaaadab7086c in _start (/home/cs300-user/section/sec3+0x86c) (BuildId: a9529991362723cd40c70a6774ae1ecb9b8efe27)

SUMMARY: AddressSanitizer: heap-use-after-free /home/cs300-user/section/sec3.c:17 in main
Shadow bytes around the buggy address:
  0x501ffffffd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501ffffffe00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501ffffffe80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501fffffff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x501fffffff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x502000000000: fa fa[fd]fa fa fa 00 fa fa fa fa fa fa fa fa fa
  0x502000000080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000100: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000180: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x502000000280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb

Sanitizer Error 3 #

==73846==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0xffffb7ee76d0 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0xaaaae87e0970 in main /home/cs300-user/section/sec3.c:6
    #2 0xffffb7c684c0 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #3 0xffffb7c68594 in __libc_start_main_impl ../csu/libc-start.c:360
    #4 0xaaaae87e086c in _start (/home/cs300-user/section/sec3+0x86c) (BuildId: 437cc22a1424450cbeaf1103702b661e7ee6432e)

SUMMARY: AddressSanitizer: 8 byte(s) leaked in 1 allocation(s).

Creative Commons Licence This work is licensed under a Creative Commons Attribution 4.0 International License.