Fixed pthread_cancel segfault bug