Regarding segmantation violation

Sekhar Pedamallu sekhar.pedamallu at patni.com
Fri Jun 1 11:21:09 UTC 2007


Plea find the attachment of the code . if u memset to 0 it fails where as to
nay other ascii it works. I m cross compiling and running on the PPC board.
Until 8109 bytes it works fine . I have even tried to see whats happening at
8110 byte I couldn't when I m running on the board .

The inputs to the program are chunck of bytes to be allocated and no of
times to allocate and free them . running the exe file at the command prompt
looks like :

  #./mem 100 1

  100 is chunk of bytes
  1   allocate and free 1 time .

 
 I m sending u two instances of the program when 100 bytes are allocated for
1 time ( does successfully for memset to 0) : (used strace )

# ./strace ./mem 100 1
execve("./mem", ["./mem", "100", "1"], [/* 15 vars */]) = 0
uname({sys="Linux", node="SBT-PXC ", ...}) = 0
brk(0)                                  = 0x10012000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x30016000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or
directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=64, ...}) = 0
mmap(NULL, 64, PROT_READ, MAP_PRIVATE, 3, 0) = 0x30017000
close(3)                                = 0
open("/lib/ppc823/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or
directory)
stat64("/lib/ppc823", 0x7fe6e208)       = -1 ENOENT (No such file or
directory)
open("/lib/libc.so.6", O_RDONLY)        = 3
read(3, "\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\24\0\0\0\1\0\1\317"..., 512)
= 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1500625, ...}) = 0
mmap(0xfeab000, 1330296, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3,
0) = 0xfeab000
mprotect(0xffd8000, 97400, PROT_NONE)   = 0
mmap(0xffe8000, 24576, PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12d000) = 0xf0
mmap(0xffee000, 7288, PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xffee000
close(3)                                = 0
mprotect(0xffe8000, 8192, PROT_READ)    = 0
mprotect(0x30025000, 4096, PROT_READ)   = 0
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) =
0x30017000
write(1, "Total time taken  8052.000000 us"..., 37Total time taken
8052.000000 usecs
) = 37
write(1, "Time for 1 loop  8052.000000 use"..., 36Time for 1 loop
8052.000000 usecs
) = 36
munmap(0x30017000, 4096)                = 0
exit_group(0)                           = ?
Process 265 detached

When I allocate 10,000 bytes 1 time (fails on memeset to 0): (used strace)


# ./strace ./mem 10000 1
execve("./mem", ["./mem", "10000", "1"], [/* 15 vars */]) = 0
uname({sys="Linux", node="SBT-PXC ", ...}) = 0
brk(0)                                  = 0x10012000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x30016000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or
directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=64, ...}) = 0
mmap(NULL, 64, PROT_READ, MAP_PRIVATE, 3, 0) = 0x30017000
close(3)                                = 0
open("/lib/ppc823/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or
directory)
stat64("/lib/ppc823", 0x7fd00208)       = -1 ENOENT (No such file or
directory)
open("/lib/libc.so.6", O_RDONLY)        = 3
read(3, "\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\24\0\0\0\1\0\1\317"..., 512)
= 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1500625, ...}) = 0
mmap(0xfeab000, 1330296, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3,
0) = 0xfeab000
mprotect(0xffd8000, 97400, PROT_NONE)   = 0
mmap(0xffe8000, 24576, PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12d000) = 0xf0
mmap(0xffee000, 7288, PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xffee000
close(3)                                = 0
mprotect(0xffe8000, 8192, PROT_READ)    = 0
mprotect(0x30025000, 4096, PROT_READ)   = 0
munmap(0x30017000, 64)                  = 0
gettimeofday({18755, 138465}, NULL)     = 0
brk(0)                                  = 0x10012000
brk(0x10033000)                         = 0x10033000
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++
Process 267 detached


Is it due to mmap or memset function in my busy box. Any more details needed
I will send .


Thanks for u r response.







Thanks & Regards ,
Sekhar Pedamallu

-----Original Message-----
From: busybox-bounces at busybox.net [mailto:busybox-bounces at busybox.net] On
Behalf Of Jason Curl
Sent: Friday, June 01, 2007 3:53 PM
To: busybox at busybox.net
Subject: Re: Regarding segmantation violation

Sekhar Pedamallu wrote:
> 
>    I m working on MPC8XX powerpc  . when I allocate memory for more than
> 10000 bytes and memset to 0 . its giving segmentation fault . When i
memset
> to any other ascii character it works fine . is it a problem with busy box
I
> m using ?
> 
> Or what could be the source of the problem ? I m new to linux .any more
> details u want I can mail u.

Can you post a completely compilable example where the problem is shown? 
Maybe a code review with your colleagues where you work can identify a 
problem?

_______________________________________________
busybox mailing list
busybox at busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox

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. 
_____________________________________________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TC1_memV2.c
Type: application/octet-stream
Size: 3425 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20070601/e47c2d61/attachment-0002.obj 


More information about the busybox mailing list