Results 1 to 10 of 10

Thread: why is there so strange "Segmentation fault" ?

  1. #1
    Join Date
    Aug 2009
    Posts
    28
    Thanks
    5
    Thanked 1 Time in 1 Post

    Angry why is there so strange "Segmentation fault" ?

    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?

  2. #2
    Join Date
    Aug 2009
    Posts
    28
    Thanks
    5
    Thanked 1 Time in 1 Post

    Unhappy Re: why is there so strange "Segmentation fault" ?

    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-qtem...-qt-23230.html

  3. #3
    Join Date
    Aug 2009
    Posts
    28
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default Re: why is there so strange "Segmentation fault" ?

    it is also not enough. my arm-gcc is 4.3.2,now it happens again,my god!

  4. #4
    Join Date
    Aug 2009
    Posts
    28
    Thanks
    5
    Thanked 1 Time in 1 Post

    Unhappy Re: why is there so strange "Segmentation fault" ?

    can any one give a word?

  5. #5
    Join Date
    Mar 2010
    Posts
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: why is there so strange "Segmentation fault" ?

    i have this similar problem with you.....have you solved it ???

  6. #6
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: why is there so strange "Segmentation fault" ?

    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.

  7. #7
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: why is there so strange "Segmentation fault" ?

    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.

  8. #8
    Join Date
    Dec 2009
    Posts
    29
    Thanks
    2
    Thanked 3 Times in 3 Posts

    Default Re: why is there so strange "Segmentation fault" ?

    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.

  9. #9
    Join Date
    Mar 2010
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: why is there so strange "Segmentation fault" ?

    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?

  10. #10
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: why is there so strange "Segmentation fault" ?

    You need to debug your application, find the source of the sigsegv, and then fix it.

Similar Threads

  1. Very strange socket programming problem
    By montylee in forum Qt Programming
    Replies: 5
    Last Post: 11th November 2008, 12:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.