add debug codes before the segfault happenes