摘要: 函数接口:int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg);int pthread_join(pthread_t thread, void **retval);int pthread_mutex_lock(pthread_mutex_t *mutex);int pthread_mutex_unlock(pthread_mutex_t *mutex);pthread_mutex_t mutex;mutex = PTHREAD_M 阅读全文
posted @ 2013-09-24 21:09 san--shi 阅读(177) 评论(0) 推荐(0)
摘要: 一 造成segment fault,产生core dump的可能原因1.内存访问越界a) 由于使用错误的下标,导致数组访问越界b) 搜索字符串时,依靠字符串结束符来判断字符串是否结束,但是字符串没有正常的使用结束符c) 使用strcpy, strcat, sprintf, strcmp, strcasecmp等字符串操作函数,将目标字符串读/写爆。应该使用strncpy, strlcpy, strncat, strlcat, snprintf, strncmp, strncasecmp等函数防止读写越界。2 多线程程序使用了线程不安全的函数。3 多线程读写的数据未加锁保护。对于会被多个线程同时 阅读全文
posted @ 2013-08-01 19:25 san--shi 阅读(324) 评论(0) 推荐(0)