I found the problem, guys.
The problem is the unit cmem!
I included it because I read that when using fpc threads we should include cthreads and cmem units as the first units in the program.
But this breaks the program everywhere, things like SetLength fail, for example.
FPC bug, or cmem is not needed anymore, or something else?