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

Author Topic: Creating a global sf::Cursor on Linux crashes the program on startup  (Read 1676 times)

0 Members and 1 Guest are viewing this topic.

Elias Daler

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
    • Blog
    • Email

#include <SFML/Window/Cursor.hpp>

sf::Cursor cursor;

int main()
{ }

Stack trace:

#0  __GI___pthread_mutex_lock (mutex=0x0) at ../nptl/pthread_mutex_lock.c:65
#1  0x00000000004ff415 in sf::priv::MutexImpl::lock (this=0x0) at /home/eliasdaler/SFML-release/SFML/src/SFML/System/Unix/MutexImpl.cpp:57
#2  0x00000000004f9ec8 in sf::Mutex::lock (this=0x75a958 <_ZN12_GLOBAL__N_15mutexE>) at /home/eliasdaler/SFML-release/SFML/src/SFML/System/Mutex.cpp:56
#3  0x00000000004f9d43 in sf::Lock::Lock (this=0x7fffffffd4f8, mutex=...) at /home/eliasdaler/SFML-release/SFML/src/SFML/System/Lock.cpp:38
#4  0x00000000004e2b5b in sf::priv::OpenDisplay () at /home/eliasdaler/SFML-release/SFML/src/SFML/Window/Unix/Display.cpp:56
#5  0x00000000004dd655 in sf::priv::CursorImpl::CursorImpl (this=0x76d940) at /home/eliasdaler/SFML-release/SFML/src/SFML/Window/Unix/CursorImpl.cpp:43
#6  0x00000000004d2106 in sf::Cursor::Cursor (this=0x753ab0 <cursor>) at /home/eliasdaler/SFML-release/SFML/src/SFML/Window/Cursor.cpp:36
#7  0x0000000000407ef7 in __cxx_global_var_init ()
#8  0x0000000000407f39 in _GLOBAL__sub_I_main.cpp ()
#9  0x00000000004ff5ed in __libc_csu_init ()
#10 0x00007ffff5dcfb28 in __libc_start_main (main=0x4093f0 <main>, argc=1, argv=0x7fffffffd6e8, init=0x4ff5a0 <__libc_csu_init>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffd6d8)
    at ../csu/libc-start.c:266
#11 0x000000000040932a in _start ()

This crash is caused by OpenDisplay() in sf::Cursor's constructor (here).

Is this expected? What if the display was opened on cursor load only? The fix should be simple in this case and I'm ready to provide a PR for it. :)
« Last Edit: August 05, 2018, 05:11:15 pm by Elias Daler »
Tomb Painter, Re:creation dev | eliasdaler.github.io | @EliasDaler | Tomb Painter dev log