SFML community forums

Help => Window => Topic started by: Robert42 on September 07, 2011, 03:18:54 pm

Title: sigsev qhen quitting after calling Window::create
Post by: Robert42 on September 07, 2011, 03:18:54 pm
I've used SFML 2.x (fetched and compiled today)

to reproduce compile the following code, run it.
press seval times (about 10 times) Tab and then quit with esc.

There are no errors on my PC (GTX 470, Ubuntu x64), but on my notebook (intel GM45, Ubuntu x64) this gets a sigsev.

Code: [Select]

#include <GL/glew.h>
#include <SFML/Window.hpp>
#include <iostream>

void init_states()
  // Set color and depth clear value
  glClearColor(0.f, 0.f, 0.f, 0.f);

  // Enable Z-buffer read and write

  // Setup a perspective projection
  gluPerspective(90.f, 1.f, 1.f, 500.f);

int main()
    sf::ContextSettings Settings;
    Settings.DepthBits         = 32; // Request a 24 bits depth buffer
    Settings.StencilBits       = 8;  // Request a 8 bits stencil buffer
    Settings.AntialiasingLevel = 4;  // Request 2 levels of antialiasing
    sf::Window App(sf::VideoMode(800, 600, 32), "SFML OpenGL", sf::Style::Close, Settings);
    // Create a clock for me
    sf::Clock Clock;


    // Start game loop
    while (App.IsOpened())
        // Process events
        sf::Event Event;
        while (App.PollEvent(Event))
            // Close window : exit
            if (Event.Type == sf::Event::Closed)

            // Escape key : exit
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Escape))
            if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Tab))
              App.Create(sf::VideoMode(800, 600, 32), "SFML OpenGL", sf::Style::Close);

            // Resize event : adjust viewport
            if (Event.Type == sf::Event::Resized)
                glViewport(0, 0, Event.Size.Width, Event.Size.Height);

        // Set the active window before using OpenGL commands
        // It's useless here because active window is always the same,
        // but don't forget it if you use multiple windows or controls

        // Clear color and depth buffer

        // Apply some transformations
        glTranslatef(0.f, 0.f, -200.f);
        //a += 0.1f;
        glRotatef(Clock.GetElapsedTime() * 0.001f * 50.f, 1.f, 0.f, 0.f);
        glRotatef(Clock.GetElapsedTime() * 0.001f * 30.f, 0.f, 1.f, 0.f);
        glRotatef(Clock.GetElapsedTime() * 0.001f * 90.f, 0.f, 0.f, 1.f);

        // Draw a cube

            glVertex3f(-50.f, -50.f, -50.f);
            glVertex3f(-50.f,  50.f, -50.f);
            glVertex3f( 50.f,  50.f, -50.f);
            glVertex3f( 50.f, -50.f, -50.f);

            glVertex3f(-50.f, -50.f, 50.f);
            glVertex3f(-50.f,  50.f, 50.f);
            glVertex3f( 50.f,  50.f, 50.f);
            glVertex3f( 50.f, -50.f, 50.f);

            glVertex3f(-50.f, -50.f, -50.f);
            glVertex3f(-50.f,  50.f, -50.f);
            glVertex3f(-50.f,  50.f,  50.f);
            glVertex3f(-50.f, -50.f,  50.f);

            glVertex3f(50.f, -50.f, -50.f);
            glVertex3f(50.f,  50.f, -50.f);
            glVertex3f(50.f,  50.f,  50.f);
            glVertex3f(50.f, -50.f,  50.f);

            glVertex3f(-50.f, -50.f,  50.f);
            glVertex3f(-50.f, -50.f, -50.f);
            glVertex3f( 50.f, -50.f, -50.f);
            glVertex3f( 50.f, -50.f,  50.f);

            glVertex3f(-50.f, 50.f,  50.f);
            glVertex3f(-50.f, 50.f, -50.f);
            glVertex3f( 50.f, 50.f, -50.f);
            glVertex3f( 50.f, 50.f,  50.f);

        static int i=0;
        std::cout<<"rendered frame "<<i++<<"\n";

        // Finally, display rendered frame on screen

    return EXIT_SUCCESS;

This is the callstack:
Code: [Select]
#0  0x00007ffff3d993c6 in ?? () from /lib/x86_64-linux-gnu/libdrm_intel.so.1
#1  0x00007ffff4924ace in ?? () from /usr/lib/dri/i965_dri.so
#2  0x00007ffff450f91c in _mesa_reference_buffer_object ()
   from /usr/lib/dri/libdricore.so
#3  0x00007ffff457da4e in ?? () from /usr/lib/dri/libdricore.so
#4  0x00007ffff454c59f in _mesa_HashDeleteAll ()
   from /usr/lib/dri/libdricore.so
#5  0x00007ffff457dd50 in _mesa_release_shared_state ()
   from /usr/lib/dri/libdricore.so
#6  0x00007ffff4518749 in _mesa_free_context_data ()
   from /usr/lib/dri/libdricore.so
#7  0x00007ffff492774e in intelDestroyContext () from /usr/lib/dri/i965_dri.so
#8  0x00007ffff491cc30 in ?? () from /usr/lib/dri/i965_dri.so
#9  0x00007ffff6c53655 in ?? () from /usr/lib/mesa/libGL.so.1
#10 0x00007ffff7bcd485 in sf::priv::GlxContext::~GlxContext (this=0x969fe0,
    __in_chrg=<value optimized out>)
    at /home/robert/FLOSS/SFML/src/SFML/Window/Linux/GlxContext.cpp:118
#11 0x00007ffff7bcd544 in sf::priv::GlxContext::~GlxContext (this=0x969fe0,
    __in_chrg=<value optimized out>)
    at /home/robert/FLOSS/SFML/src/SFML/Window/Linux/GlxContext.cpp:131
#12 0x00007ffff7bc5aaf in sf::priv::GlContext::GlobalCleanup ()
---Type <return> to continue, or q <return> to quit---
    at /home/robert/FLOSS/SFML/src/SFML/Window/GlContext.cpp:128
#13 0x00007ffff7bc7021 in sf::GlResource::~GlResource (this=0x7fffffffe060,
    __in_chrg=<value optimized out>)
    at /home/robert/FLOSS/SFML/src/SFML/Window/GlResource.cpp:78
#14 0x00007ffff7bca1d3 in sf::Window::~Window (this=0x7fffffffe060,
    __in_chrg=<value optimized out>)
    at /home/robert/FLOSS/SFML/src/SFML/Window/Window.cpp:80
#15 0x0000000000401b61 in main ()