开发者

c, segmentation fault

开发者 https://www.devze.com 2023-03-27 02:49 出处:网络
Can anyone please tell me why I have segmentation fault here? void *dispatcher_th开发者_如何学Goreadloop(void * queue){

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

精彩评论

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