Infinit loop when I 'print_r' variables like $form_state, $form
You might not like the answer, but it's still true: Don't use print_r() for $form/$form_state, entity or other complex objects. It just doesn't work.

Try kint() from the devel module instead, make sure to install the kint submodule too.