Regarding segmantation violation

Tito farmatito at tiscali.it
Fri Jun 1 13:38:27 UTC 2007


On Friday 01 June 2007 14:47:08 you wrote:
> Used calloc and bzero and tried , but couldn't get resolved .
> 
>  
> 
> Thanks & Regards ,
> 
> Sekhar Pedamallu
BTW.: your code works fine here on my box x86.

Why are you thinking that the SEGV happens at malloc/memset/free stage?

munmap(0x30017000, 64)                  = 0
gettimeofday({18672, 446432}, NULL)     = 0
brk(0)                                  = 0x10012000
brk(0x10033000)                         = 0x10033000
gettimeofday({18672, 454484}, NULL)     = 0
fstat64(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(204, 46), ...}) = 0
ioctl(1, TCGETS, {B115200 opost isig icanon echo ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) 

gettimeofday({18755, 138465}, NULL)     = 0
brk(0)                                  = 0x10012000
brk(0x10033000)                         = 0x10033000
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++
Process 267 detached


Looks to me that it happens at the stage of the second gettimeofday call....
Did you try the same code without all this timer stuff

int main(int argc, char **argv)
{
	free(memset(malloc(10000), 0, 10000));
	return 0
}

Hope this helps.

Ciao,
Tito



> From: Tito [mailto:farmatito at tiscali.it] 
> Sent: Friday, June 01, 2007 6:05 PM
> To: busybox at busybox.net; sekhar.pedamallu at patni.com
> Subject: Re: Regarding segmantation violation
> 
>  
> 
> On Friday 01 June 2007 13:21:09 Sekhar Pedamallu wrote:
> 
> for(l_iIndex = 0; l_iIndex < l_iCount ; l_iIndex++)
> 
> {
> 
> l_pcTemp = (char *)malloc(l_iSize); 
> 
> if(NULL == l_pcTemp)
> 
> {
> 
> printf("Memory allocation failed \n"); 
> 
> exit(1);
> 
> }
> 
> // printf(" Start Address %p \n",l_pcTemp);
> 
> // printf(" End Address %p \n",l_pcTemp+l_iSize-1); 
> 
> ====> memset(l_pcTemp,0,l_iSize); maybe memset(l_pcTemp,0,strlen(l_pcTemp));
> will work better???
> 
> free(l_pcTemp);
> 
> } 
> 
> BTW: you can use calloc() instead of malloc() + memset()
> 
> Ciao,
> 
> Tito
> 
> 
> http://www.patni.com
> World-Wide Partnerships. World-Class Solutions.
> _____________________________________________________________________
> 
> This e-mail message may contain proprietary, confidential or legally
> privileged information for the sole use of the person or entity to
> whom this message was originally addressed. Any review, e-transmission
> dissemination or other use of or taking of any action in reliance upon
> this information by persons or entities other than the intended
> recipient is prohibited. If you have received this e-mail in error
> kindly delete  this e-mail from your records. If it appears that this
> mail has been forwarded to you without proper authority, please notify
> us immediately at netadmin at patni.com and delete this mail. 
> _____________________________________________________________________
> 





More information about the busybox mailing list