SFML community forums

Help => Window => Topic started by: OniLinkPlus on November 21, 2010, 09:28:26 pm

Title: Segmentation Fault when Window is Closed
Post by: OniLinkPlus on November 21, 2010, 09:28:26 pm
Every time I close an SFML window on Linux, I get a segmentation fault. It even happens in the examples.
Title: Segmentation Fault when Window is Closed
Post by: Laurent on November 21, 2010, 09:39:07 pm
Which version of SFML? Are you sure that you don't have more than one version of SFML installed?
Title: Segmentation Fault when Window is Closed
Post by: OniLinkPlus on November 21, 2010, 09:41:01 pm
Quote from: "Laurent"
Which version of SFML? Are you sure that you don't have more than one version of SFML installed?
I have the latest build of SFML2. In the cmake generated makefiles, is there a way to remove the installed SFML2 so I can be sure there's only one installed?

EDIT: yes, only one version of SFML is installed.
Title: Segmentation Fault when Window is Closed
Post by: Laurent on November 21, 2010, 10:05:54 pm
Are you really sure? Because I have changed SFML 2 libraries names and path many times.
Title: Segmentation Fault when Window is Closed
Post by: OniLinkPlus on November 21, 2010, 10:10:16 pm
Quote from: "Laurent"
Are you really sure? Because I have changed SFML 2 libraries names and path many times.
Yes, I went into /usr/lib, /usr/local/lib, /usr/include, and /usr/local/include, deleted everything SFML, and reinstalled.
Title: Segmentation Fault when Window is Closed
Post by: Laurent on November 21, 2010, 10:12:37 pm
There's no known bug on Linux, something must be wrong but I don't know what if there's only one version of SFML on your PC and it's properly installed.
Title: Segmentation Fault when Window is Closed
Post by: Groogy on November 21, 2010, 10:33:44 pm
Maybe he can specify some info about the graphics card and drivers? Also probably give you the call stack when the app crashes.

Segmentation Fault is generated when you are accessing memory that isn't yours to touch. Like NULL or something like that. If it isn't a generic Linux bug then I would say it is something specific to his computer which would be the drivers.
Title: Segmentation Fault when Window is Closed
Post by: OniLinkPlus on November 22, 2010, 12:04:24 am
Quote from: "Groogy"
Maybe he can specify some info about the graphics card and drivers? Also probably give you the call stack when the app crashes.

Segmentation Fault is generated when you are accessing memory that isn't yours to touch. Like NULL or something like that. If it isn't a generic Linux bug then I would say it is something specific to his computer which would be the drivers.
I have an ATi HD4850, and I'm using the open-source drivers. How would I go about getting the call stack?
Title: Segmentation Fault when Window is Closed
Post by: Groogy on November 22, 2010, 12:06:25 am
If you are using Code::Blocks then you can just take a screenshot while debugging the application that crashes and having the "CallStack" window open of course.
Title: same issue
Post by: ekun on December 01, 2010, 07:34:09 pm
I'm having the same issue.

When I close a window, a segmentation fault occurs.
The call stack points to
c:\windows\system32\ig4dev32.dll

The code is perfect and very minimal. I have not had this problem using SFML 1.6, Im using the latest build of SFML 2.0.

-Windows 7 32-bit
-Intel integrated graphics card
-Code blocks mingw32

The funny thing is, I've had this error before on another project. The project was fairly complicated, and although I had the same problem initially, it disappeared as development went on. It seems to only occur when I use a minimal example:

Code: [Select]

    sf::RenderWindow window(sf::VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, 32), "solo");

    while(window.IsOpened())
    {
        sf::Event windowEvent;
        while(window.GetEvent(windowEvent))
        {
            if(windowEvent.Type == sf::Event::Closed)
                window.Close();
        }

        window.Clear();
        window.Display();
    }
Title: Segmentation Fault when Window is Closed
Post by: Svenstaro on December 01, 2010, 08:03:29 pm
I'm getting the same. I've been getting it for long but I didn't think much about it since it doesn't have any ill effects. The backtrace shows the segfault occurring deep inside my r300g driver. That's the mesa radeon driver with the gallium framework.
Title: Segmentation Fault when Window is Closed
Post by: OniLinkPlus on December 02, 2010, 02:01:02 am
Glad to know I'm not the only one with this problem. Reassures me that I haven't gone completely insane yet.
Title: Segmentation Fault when Window is Closed
Post by: LeeZH on January 22, 2011, 03:51:55 pm
Sorry for digging up this old article, but I think it's because the code would call window.Clear() and window.Display() after window.Close() is called. You should use probably use:

Code: [Select]
   sf::RenderWindow window(sf::VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, 32), "solo");

    while(window.IsOpened())
    {
        sf::Event windowEvent;
        while(window.GetEvent(windowEvent))
        {
            if(windowEvent.Type == sf::Event::Closed)
            {
                window.Close();
                return; // <-- FIX
            }
        }

        window.Clear();
        window.Display();
    }
Title: Segmentation Fault when Window is Closed
Post by: JAssange on January 22, 2011, 06:53:08 pm
Quote from: "LeeZH"
Sorry for digging up this old article, but I think it's because the code would call window.Clear() and window.Display() after window.Close() is called. You should use probably use:

Code: [Select]
   sf::RenderWindow window(sf::VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, 32), "solo");

    while(window.IsOpened())
    {
        sf::Event windowEvent;
        while(window.GetEvent(windowEvent))
        {
            if(windowEvent.Type == sf::Event::Closed)
            {
                window.Close();
                return; // <-- FIX
            }
        }

        window.Clear();
        window.Display();
    }


That shouldn't cause an issue, it doesn't on Windows. Does this only happen in the debugger? On Windows I get this issue but only when running from Visual Studio.
Title: Segmentation Fault when Window is Closed
Post by: Laurent on January 22, 2011, 07:08:59 pm
Using a closed sf::Window is fine, users don't have to worry about that.
Title: Segmentation Fault when Window is Closed
Post by: LeeZH on January 22, 2011, 08:37:19 pm
I took the code and tried compiling it. No problems at all, even with GDB running with breakpoints. Oh well, sorry for the pointless digging. I guess I should have tested it out before I posted.