开发者

c, segmentation fault

Can anyone please tell me why I have segmentation fault here?

   void *dispatcher_th开发者_如何学Goreadloop(void * queue){

//thread loop of the dispatch thread- pass the tast to one of worker thread
dispatch_queue_t *dQueue;

printf("message-boss1");
dQueue = (dispatch_queue_t *)queue;
if (dQueue->HEAD!=NULL){
    for(;;){
        sem_wait(dQueue->queue_thread_semaphore);
        //TODO
    }
}

printf("message-boss2");

}


queue is probably 0 or points to some invalid location in memory.

If you want more help, see http://sscce.org/


If you don't feel like checking dQueue against null, or if dQueue being null should never happen, try an assertion

dispatch_queue_t *dQueue = queue;

assert(dQueue!=NULL)

On the other hand, you should probably post the origin of the queue variable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜