I am at the very beginning of learning C.
I am trying to write a function to open a file, read a BUFFER_SIZE
, store the content in an array, then track the character '\n'
(because I want to get each line of the input).
when I set the BUFFER_SIZE
very large, I can get the first line. when I set the BUFFER_SIZE
reasonably small (say, 42) which is not yet the end of the first line , it prints out some weird symbol at the end, but I guess it is some bug in my own code.
however, when I set the BUFFER_SIZE
very small, say = 10, and i use the -fsanitizer=address
to check for memory leak. it throws a monster of error:
==90673==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020000000fb at pc 0x000108868a95 bp 0x7fff573979a0 sp 0x7fff57397998
READ of size 1 at 0x6020000000fb thread T0
If anyone can explain me in a general sense:
what is fsanitizer=address flag?
what is heap-buffer-overflow?
what is address and thread? what is the flag to see the thread in colors on screen?
and why it says 'read of size 1 at address.." ?
i would really appreciate <3