c、分段错误
谁能告诉我为什么这里出现分段错误?
void *dispatcher_threadloop(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");
}
Can anyone please tell me why I have segmentation fault here?
void *dispatcher_threadloop(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");
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
queue
可能为 0 或指向内存中的某个无效位置。如果您需要更多帮助,请参阅 http://sscce.org/
queue
is probably 0 or points to some invalid location in memory.If you want more help, see http://sscce.org/
如果您不想检查 dQueue 是否为 null,或者如果 dQueue 为 null 永远不应该发生,请尝试断言
另一方面,您可能应该发布
queue
变量。If you don't feel like checking
dQueue
against null, or ifdQueue
being null should never happen, try an assertionOn the other hand, you should probably post the origin of the
queue
variable.