Memory Permission error ! 038038C0

probably this code.
You are using encoders before they exist, and that code also has no real use at that point, remember all this is doing is initializing a variable (not to mention you are not asking for the encoder values correctly)

unrelated to the memory errors, but you should also read through this as task management in that code may cause issues.