segmentation fault with loopback query