Hi,
I have been able to run Michel Xhaard's spcaview (spcaClient) on VMware
Linux pc but when I ran it on friendlyarm9 I get a segmentation fault. I
changed the memory on the Vmware to the memory but it still run well. After
reading about segmentation fault error, I suspect the only function in
spcaClient that access memory. The function is below:
void resize (unsigned char *dst,unsigned char *src, int Wd,int Hd,int
Ws,int Hs)
{
int rx,ry;
int xscale,yscale;
int x,y;
Myrgb24 pixel;
Myrgb24 *output =(Myrgb24*) dst ;
Myrgb24 *input = (Myrgb24*) src ;
xscale = (Ws << 16)/Wd;
yscale = (Hs << 16)/ Hd;
for (y = 0; y < Hd; y++){
for (x = 0; x < Wd; x++){
rx = x*xscale >> 16;
ry = y*yscale >> 16;
memcpy(output++,&input[ADDRESSE((int)rx,(int)ry,Ws)],sizeof(Myrgb24));
}
}
}
I will be grateful for any helpful leads. Currently am using gdb to debug
and making changes to the function to see if I get rid of the error.
Thanks.
---------------------------------------
Posted through http://www.EmbeddedRelated.com
|
|
0
|
|
|
|
Reply
|
najafa
|
10/22/2010 3:52:00 AM |
|
On Oct 21, 11:52=A0pm, "najafa" <nabakah@n_o_s_p_a_m.gmail.com> wrote:
> Hi,
> I have been able to run Michel Xhaard's spcaview (spcaClient) on VMware
> Linux pc but when I ran it on friendlyarm9 I get a segmentation fault. I
> changed the memory on the Vmware to the memory but it still run well. Aft=
er
> reading about segmentation fault error, I suspect the only function in
> spcaClient that access memory. The function is below: =A0
>
> void resize (unsigned char *dst,unsigned char *src, int Wd,int Hd,int
> Ws,int Hs)
> {
> =A0 =A0 =A0 =A0 int rx,ry;
> =A0 =A0 =A0 =A0 int xscale,yscale;
> =A0 =A0 =A0 =A0 int x,y;
> =A0 =A0 =A0 =A0 Myrgb24 pixel;
> =A0 =A0 =A0 =A0 Myrgb24 *output =3D(Myrgb24*) dst ;
> =A0 =A0 =A0 =A0 Myrgb24 *input =3D (Myrgb24*) src ;
>
> =A0 =A0 =A0 =A0 xscale =3D =A0(Ws << 16)/Wd;
> =A0 =A0 =A0 =A0 yscale =3D (Hs << 16)/ Hd;
> =A0 =A0 =A0 =A0 for (y =3D 0; y < Hd; y++){
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 for (x =3D 0; x < Wd; x++){
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0rx =3D x*xscale >> 16;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ry =3D y*yscale >> 16;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0memcpy(output++,&input[ADDRESSE((int)r=
x,(int)ry,Ws)],sizeof(Myrgb24));
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 }
>
> }
>
> I will be grateful for any helpful leads. Currently am using gdb to debug
> and making changes to the function to see if I get rid of the error.
> Thanks. =A0 =A0
>
Just keep in mind the problem may occur in that routine, but the real
source may be elsewhere. It might show up in this routine if a pointer
is trashed by some higher level routine and then passed into this
routine. You should get some clues from the call stack in gdb.
HTH,
ed
|
|
0
|
|
|
|
Reply
|
edprochak (546)
|
10/22/2010 5:57:42 AM
|
|
najafa wrote:
> Hi,
> I have been able to run Michel Xhaard's spcaview (spcaClient) on VMware
> Linux pc but when I ran it on friendlyarm9 I get a segmentation fault. I
> changed the memory on the Vmware to the memory but it still run well. After
> reading about segmentation fault error, I suspect the only function in
> spcaClient that access memory. The function is below:
>
> void resize (unsigned char *dst,unsigned char *src, int Wd,int Hd,int
> Ws,int Hs)
> {
> int rx,ry;
> int xscale,yscale;
> int x,y;
> Myrgb24 pixel;
> Myrgb24 *output =(Myrgb24*) dst ;
> Myrgb24 *input = (Myrgb24*) src ;
>
> xscale = (Ws << 16)/Wd;
> yscale = (Hs << 16)/ Hd;
> for (y = 0; y < Hd; y++){
> for (x = 0; x < Wd; x++){
> rx = x*xscale >> 16;
> ry = y*yscale >> 16;
> memcpy(output++,&input[ADDRESSE((int)rx,(int)ry,Ws)],sizeof(Myrgb24));
> }
> }
>
>
>
> }
>
> I will be grateful for any helpful leads. Currently am using gdb to debug
> and making changes to the function to see if I get rid of the error.
> Thanks.
Maybe the stack size on the ARM system is smaller. Check if there are
functions in which something large like a buffer is declared. This might
overwrite other stuff when it is larger than the stack and this can
cause segmentation faults. If this is so, try if making it static helps.
Good luck!
Greetings,
Rene
|
|
0
|
|
|
|
Reply
|
Rene
|
10/22/2010 9:29:05 AM
|
|
Am 22.10.2010 05:52, schrieb najafa:
> Hi,
> I have been able to run Michel Xhaard's spcaview (spcaClient) on VMware
> Linux pc but when I ran it on friendlyarm9 I get a segmentation fault. I
> changed the memory on the Vmware to the memory but it still run well. After
> reading about segmentation fault error, I suspect the only function in
> spcaClient that access memory. The function is below:
You may run into problems with misaligned memory accesses. Many RISC
processors require 32bit accesses at multiples of four and 16bit acesses
at multiples of two. If the memory adresses do not satisfy these
requirements the processor has to split the memory access into two
accesses. The Intel x86 does this, many RISC architectures (including
ARM9) don't and throw exceptions instead.
--
Mit freundlichen Gr��en
Frank-Christian Kr�gel
|
|
0
|
|
|
|
Reply
|
ISO
|
10/22/2010 8:57:01 PM
|
|
|
3 Replies
414 Views
(page loaded in 0.046 seconds)
|