Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Segmentation Fault when Window is Closed  (Read 10247 times)

0 Members and 1 Guest are viewing this topic.

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Segmentation Fault when Window is Closed
« 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.
I use the latest build of SFML2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Segmentation Fault when Window is Closed
« Reply #1 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?
Laurent Gomila - SFML developer

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Segmentation Fault when Window is Closed
« Reply #2 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.
I use the latest build of SFML2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Segmentation Fault when Window is Closed
« Reply #3 on: November 21, 2010, 10:05:54 pm »
Are you really sure? Because I have changed SFML 2 libraries names and path many times.
Laurent Gomila - SFML developer

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Segmentation Fault when Window is Closed
« Reply #4 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.
I use the latest build of SFML2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Segmentation Fault when Window is Closed
« Reply #5 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.
Laurent Gomila - SFML developer

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Segmentation Fault when Window is Closed
« Reply #6 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.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Segmentation Fault when Window is Closed
« Reply #7 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?
I use the latest build of SFML2

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Segmentation Fault when Window is Closed
« Reply #8 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.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

ekun

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • Vagante
    • Email
same issue
« Reply #9 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();
    }
@ekunenuke

Svenstaro

  • Full Member
  • ***
  • Posts: 222
    • View Profile
Segmentation Fault when Window is Closed
« Reply #10 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.

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Segmentation Fault when Window is Closed
« Reply #11 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.
I use the latest build of SFML2

LeeZH

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • http://leezh.net/
Segmentation Fault when Window is Closed
« Reply #12 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();
    }
I'm just a college student who does game programming as a hobby.

JAssange

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Segmentation Fault when Window is Closed
« Reply #13 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Segmentation Fault when Window is Closed
« Reply #14 on: January 22, 2011, 07:08:59 pm »
Using a closed sf::Window is fine, users don't have to worry about that.
Laurent Gomila - SFML developer