How to use WP_Query() on single.php?

$query->the_post;

should be:

$query->the_post();

The first is trying to fetch a property named the_post rather than invoking the function so the post never advances, and your loop is infinite.