SFML community forums

General => General discussions => Topic started by: Kojay on June 28, 2015, 11:23:49 pm

Title: Invalid read in KDE
Post by: Kojay on June 28, 2015, 11:23:49 pm
Hello,

I 'm on Kubuntu 15.04 and running SFML applications through valgrind, they produce the following invalid read:

==14802== Invalid read of size 1
==14802==    at 0x4C2F134: strlen (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14802==    by 0x5314CC7: sf::String::String(char const*, std::locale const&) (String.cpp:73)
==14802==    by 0x50E10B7: (anonymous namespace)::ewmhSupported() (WindowImplX11.cpp:235)
==14802==    by 0x50E2849: sf::priv::WindowImplX11::WindowImplX11(sf::VideoMode, sf::String const&, unsigned long, sf::ContextSettings const&) (WindowImplX11.cpp:579)
==14802==    by 0x50D9BED: sf::priv::WindowImpl::create(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&) (WindowImpl.cpp:71)
==14802==    by 0x50D9188: sf::Window::create(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&) (Window.cpp:124)
==14802==    by 0x4E8D9E8: sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&) (RenderWindow.cpp:45)
==14802==    by 0x4015F3: main (main.cpp:5)
 

suggesting that a non-null terminated string has been passed to strlen; in fact the string passed to it when valgrind complains is "KWin0/inA" - it is the name of the window manager, obtained from line 233 of WindowImplX11:

const char* name = reinterpret_cast<const char*>(xcb_get_property_value(wmName.get()));
 

If I had to guess, it was supposed to be "KWin" but they got their slash the wrong way round. In any case, if this is correct it is not SFML's fault, but you may have an idea how to guard against receiving such a problematic string; or perhaps you have other thoughts on the issue.
Title: Re: Invalid read in KDE
Post by: binary1248 on June 28, 2015, 11:43:48 pm
#892 (https://github.com/SFML/SFML/issues/892),#901 (https://github.com/SFML/SFML/issues/901),#918 (https://github.com/SFML/SFML/issues/918)
Title: Re: Invalid read in KDE
Post by: Kojay on June 29, 2015, 01:22:06 am
Good.