View Full Version : [C] Ancora Bus Error...
Ed_Bunker
23-11-2004, 23:49
Ciao, nessuno che sappia indicarmi una possibile "fonte" di bus error nel codice (Quando eseguito) di questa funzione ?
(Supponendo che i moduli chiamanti e quelli "chiamati" siano a posto...)
thks
ilsensine
24-11-2004, 20:32
Dovresti allegare un qualche codice che consente di riprodurre il problema e debuggare in locale...
Ed_Bunker
25-11-2004, 08:04
Originariamente inviato da ilsensine
Dovresti allegare un qualche codice che consente di riprodurre il problema e debuggare in locale...
Il fatto e' che i file sono un po' troppi... :(
Comunque il codice che causa l'errore e' questo ma ancora non ho capito il motivo...
...
//fd0 e' un descrittore di dile
//fd e' un "descrittore di pipe"
int ps = getpagesize();
char * p = mmap(NULL, ((((a.st_size)/ps)+1)*ps), PROT_READ, MAP_SHARED, fd0, 0);
if (p == NULL)
{
perror("fileAllString_3: mmap");
f = FAILURE;
return f;
}
/*p e' il puntatore all'area di memoria dove...*/\
/*Posso gia' chiudere il file...*/
if ((close(fd0)) == -1)
perror("fileAllString_3: error closeing file");
/*Cerco subString all'interno di p*/
char * firstOcc = strstr(p, subString);
if (firstOcc != NULL)
{/*Sottostringa trovata*/
int pos = firstOcc - p ;
if (munmap(p, ((((a.st_size)/ps)+1)*ps)) == -1)
perror("fileAllString_3: error on munmap");
...
if (write(fd, &pos, sizeof(int)) != sizeof(int))
{
perror("fileAllString_3: error writing on client pipe" );
f = FAILURE;
return f;
}
f = TRUE;
return f;
}
/*Altrimenti faccio solo la munmap*/
if (munmap(p, ((((a.st_size)/ps)+1)*ps)) == -1)
perror("fileAllString_3: error on munmap");
...
Notate qualche errore nella mmap,munpmap o nella chiamata a strstr ?!?
thks
ilsensine
25-11-2004, 08:14
intanto correggi questo:
char * p = mmap(NULL, ((((a.st_size)/ps)+1)*ps), PROT_READ, MAP_SHARED, fd0, 0);
if (p == NULL)...
^^^^^^^^^^^^^^^^^
Cosa ritorna la mmap quando fallisce? ;)
ilsensine
25-11-2004, 08:18
Il resto sembra corretto, dovresti investigare con gdb su quale è la funzione che fallisce.
Ed_Bunker
25-11-2004, 10:05
Originariamente inviato da ilsensine
intanto correggi questo:
char * p = mmap(NULL, ((((a.st_size)/ps)+1)*ps), PROT_READ, MAP_SHARED, fd0, 0);
if (p == NULL)...
^^^^^^^^^^^^^^^^^
Cosa ritorna la mmap quando fallisce? ;)
"MAP_FAILED (-1) is returned"
:eek:
vBulletin® v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.