free ram or read ram ?

“Adding the function changes the memory layout of the compiled program. ”

This explains that behaviour. I was writing to a 4th element of the array which was declared as 3 element array and that was causing one of my global variables to change its value.