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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Ammorth

Pages: [1]
1
General / Random Crashing in Multi-threaded Project.
« on: July 02, 2013, 07:11:07 am »
So I started working with SFML for a personal project and ran into a weird issue with SFML and controlling the rendering in a second thread.  I get random crashes from X and/or xcb, usually involving an unknown request in the queue or a request in the queue during a dequeue.

Using the current build of SFML from git (as of 9:55pm PDT) on master branch.  Using Linux Mint 14 with all packages updated and kernel 3.5.0-17-generic.

build command is
g++ src/engine.cpp -Wall -std=c++0x -o3 -lsfml-graphics -lsfml-window -lsfml-system -o build/engine

This is the trimmed down version which causes the problems:

#include <SFML/Graphics.hpp>

void renderThread_entry(sf::RenderWindow* window)
{
    while (window->isOpen())
    {
        window->clear();
        window->display();
    }
}


int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "XCB Error Test");
    window.setActive(false);
       
    sf::Thread renderThread(&renderThread_entry, &window);
    renderThread.launch();

    while (window.isOpen())
    {
        sf::Event event;
        if (window.waitEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                window.close();
            }
        }    
    }

    renderThread.wait();

    return 0;
}

Commenting out all the event stuff in the main function stops the random crashing.  Add a sleep timer to the drawing thread to show that it doesn't happen on program start, but rather after a random period of time.

Some of the specific errors I get.

Quote
[xcb] Unknown request in queue while dequeuing
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
engine: ../../src/xcb_io.c:179: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed.
Aborted

Quote
[xcb] Unknown request in queue while dequeuing
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0.0"
      after 1900 requests (1900 known processed) with 1 events remaining.
engine: ../../src/xcb_io.c:179: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed.
Aborted

Quote
X Error of failed request:  BadIDChoice (invalid resource ID chosen for this connection)
  Major opcode of failed request:  139 (XFIXES)
  Minor opcode of failed request:  5 (XFixesCreateRegion)
  Resource id in failed request:  0x3e00064
  Serial number of failed request:  435
  Current serial number in output stream:  436

Again, these are "random" crashes in that they happen after a random period of time.  If it doesn't crash right away, either wait a bit or close it and try running again.

Thanks for the help.

Pages: [1]
anything