Originally Posted by
MK27
[snip]
However, maybe there are circumstances where the OS responds to SIGSEGV by explicitly SIGKILLing the process's children, which is probably what is happening here. 1241 was killed by SIGSEGV -- the sigkills are to other processes. Makes sense if you are using pthreads I guess.*
In any case, as Kennedy points out, your problem is the seg fault, plain and simple. You need to solve that -- regardless of the mechanism, a segmentation fault must cause the violating process to die because it cannot be allowed to access memory outside of itself.
[snip]
Okay, I found one of the SIGSEGVs I believe. It's because pointers were freed but not set to NULL which would cause stale pointers... that'been corrected.
However, I still seem to be getting a segfault every now and then (a lot less often)... I caught them with strace,
once I got this one:
Code:
[pid 15389] sched_setscheduler(15389, SCHED_OTHER, { 0 }) = 0
[pid 15389] --- SIGSEGV (Segmentation fault) @ 0 (0) ---
and another time it looked like this:
Code:
[pid 19908] getdents(20, /* 13 entries */, 3933) = 308
[pid 19908] --- SIGSEGV (Segmentation fault) @ 0 (0) ---
Can I say that the most recent line before the segfault is what is making the seg fault happening?
If so, in the 2nd occurence, getdents is referring to my getdir() function which looks like this:
Code:
int getdir(char *path, char ***filelist)
{
int items=0;
char **temp=NULL;
char filename[1024]={0};
struct dirent *dp;
DIR *dir = opendir(path);
if (dir==NULL){
syslog(LOG_NOTICE, "nlog: Error opening log_record directory %s, Errno: %s", path, strerror( errno ));
printf("Error opening log_record directory %s, Errno: %s", path, strerror( errno ));
return -1;
}
while((dp=readdir(dir))!=NULL){
if(strstr(dp->d_name, "log_record")!=NULL){
//sprintf(filename,"%s%s",path,dp->d_name);
snprintf(filename,sizeof(filename),"%s%s",path,dp->d_name);
temp = realloc((*filelist), (items+1) * sizeof(*temp));
if (temp == NULL) {
while (--items >= 0)
free ((*filelist)[items]);
free ((*filelist));
syslog(LOG_NOTICE, "nlog: Error reallocating memory in filelist\n");
printf("Error reallocating memory for filelist\n");
closedir(dir);
return -1;
}
(*filelist) = temp;
(*filelist)[items] = malloc(strlen(filename)+1);
if ((*filelist)[items] == NULL) {
syslog(LOG_NOTICE, "nlog: Error allocating memory for filename\n");
return -1;
}
strcpy ((*filelist)[items], filename);
++items;
}
}
closedir(dir);
return items;
}
Any one a clue what may be wrong here?
Thanks!