PDA

View Full Version : why is there so strange "Segmentation fault" ?



lanmanck
12th September 2009, 05:50
i run my program on x86 perfectly.
when i move to ARM (S3c2440), it often prompts "Segmentation fault".(not illegal pointer)
and it is very very strange:
1、sometimes i should declear a variable as a global, not a member:
xxx.h
public:
int iii; //it report "Segmentation fault"

when i put it in xxx.cpp as a global variable:
static int iii;
it works!

2、sometimes i can't init a member in construction function:
Myclass::myclass()
{
bbb=0; //it report "Segmentation fault"
}
but sometimes i can declare it as a global,and init it.

3、sometime i cannot call QTClass's member function "setValue"(or others)
4、etc。。。

strangely, these situation do not happen on X86.
why?????
is there something i should do on arm platform, or my configuration is not correct?

lanmanck
12th September 2009, 07:24
i found out that i should add -g to makefile , not default -O2(and O1 may sometime work)
here is the similar topic:
http://www.qtcentre.org/forum/f-qtembedded-qtwince-qts60-14/t-arm-platform-segfaults-with-release-qt-but-works-great-with-debug-qt-23230.html

lanmanck
12th September 2009, 17:24
it is also not enough. my arm-gcc is 4.3.2,now it happens again,my god!

lanmanck
14th September 2009, 14:29
can any one give a word?

xiston
1st March 2010, 18:10
i have this similar problem with you.....have you solved it ???

squidge
1st March 2010, 18:40
It means you are accessing illegal memory. Changing compiler flags will not fix it, although it may make the problem go elsewhere. You need to find the root of the problem in your code.

lni
2nd March 2010, 01:33
In linux, you can use valgrind. I am not sure if windows has valgrind. Do google search on valgrind to see what it is if you don't know it.

yodasoda
2nd March 2010, 08:54
are you sure you update of gcc was succesfull? What if something is wrong with your compiler and it doesnt catch the segmentation fault. At this point I would look at your code and comment some code until you see the problem stops to pin point it.

harrison
2nd March 2010, 10:06
i built my program on ubuntu with qt creator successfully, and then i ran it failed by given the output "Segmentation fault".
now i can do nothing, anybody can be nice to tell me why?

squidge
2nd March 2010, 13:55
You need to debug your application, find the source of the sigsegv, and then fix it.