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

Author Topic: [SOLVED] Failed to create input context for window  (Read 2970 times)

0 Members and 1 Guest are viewing this topic.

nboisvert

  • Newbie
  • *
  • Posts: 6
    • View Profile
[SOLVED] Failed to create input context for window
« on: June 08, 2020, 07:51:15 pm »
Hi everyone,

Before going on any further, I want to say that I do have checked the forum and google for information about this and I couldn't find any piece of information to help me.

I created a basic SFML project on CLion using Conan as a package manager. Everything builds successfully so I guess everything is correctly linked. But when I launch the program, it opens a window and then automatically crashes with the following message:

Failed to create input context for window -- TextEntered event won't be able to return unicode
free(): invalid pointer
 

I think that this might be caused by the i3wm I use but I'm not competely sure.

Code that is run:
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

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

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}
 

Gives the same error message with the following code
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
}
 

In the source I found out that it crashes exactly here https://github.com/oprypin/sfml/blob/20af2a4dfacac81407521f7812ea04fe5f7216b0/src/SFML/Window/Unix/WindowImplX11.cpp#L792

OS details:
Ubuntu 18.04
Clion 2020.1
SFML 2.5.2typo, it's SFML 2.5.1
i3wm

Any help would be really appreciated, thank you all!

P.S. This is the first time I setup SFML in ubuntu so I wouldn't surprised to know that it is a missing configuration.
« Last Edit: June 08, 2020, 10:13:07 pm by nboisvert »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Failed to create input context for window
« Reply #1 on: June 08, 2020, 08:36:45 pm »
An error message isn't equal to a crash. Do you get an actual crash or just the error shown?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

nboisvert

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Failed to create input context for window
« Reply #2 on: June 08, 2020, 08:48:33 pm »
It does crashses, the opening window is closing right away it exits. I forgot to include the exit code also which is:


Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Failed to create input context for window
« Reply #3 on: June 08, 2020, 08:56:38 pm »
Any reason you're not linking to the official SFML repository?
Also SFML 2.5.2 is not a thing, do you mean SFML 2.5.1 or do you have a modified copy of SFML?

What's the stack trace for the crash?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

nboisvert

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Failed to create input context for window
« Reply #4 on: June 08, 2020, 09:02:27 pm »
You're right, 2.5.1, my finger might have slipped without noticing.

Back then when I used to install SFML back on Windows/macOS I had a ton of issue and found the setup process clunky. That's why I went with a package manager. I would be really suprise to learn that it's a linking issue.

I don't have any stacktrace, all I have is this

Code: [Select]
/home/nboisvert/CLionProjects/untitled/cmake-build-debug/bin/untitled
Failed to create input context for window -- TextEntered event won't be able to return unicode
free(): invalid pointer

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Failed to create input context for window
« Reply #5 on: June 08, 2020, 09:13:26 pm »
Run it through a debugger (e.g. gdb) and when it crashes, retrieve the stack trace (e.g. in gdb with bt).

But if you use Ubuntu 18.04 and the SFML version provided by the package manager, you're actually using SFML 2.4.2, so maybe the typo was with the 5 and not with the 2. ;D

Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

nboisvert

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Failed to create input context for window
« Reply #6 on: June 08, 2020, 09:55:22 pm »
No I confirm it runs on Conan installed SFML 2.5.1 using the following conanfile.txt

Code: [Select]
[requires]
sfml/2.5.1@bincrafters/stable

[generators]
cmake

The exact same project works flawlessly on macOS 10.15.5. I'm pretty sure it's related to x11/i3wm on my Ubuntu PC.

The stacktrace that Clion gives
Code: [Select]
__GI_raise 0x00007f2b2890ee97
__GI_abort 0x00007f2b28910801
__libc_message 0x00007f2b28959897
malloc_printerr 0x00007f2b2896090a
_int_free 0x00007f2b28967e1c
__GI___libc_free 0x00007f2b28967e1c
__gnu_cxx::new_allocator<unsigned int>::deallocate new_allocator.h:125
std::allocator_traits<std::allocator<unsigned int> >::deallocate alloc_traits.h:462
std::__cxx11::basic_string<unsigned int, std::char_traits<unsigned int>, std::allocator<unsigned int> >::_M_destroy basic_string.h:226
std::__cxx11::basic_string<unsigned int, std::char_traits<unsigned int>, std::allocator<unsigned int> >::_M_dispose basic_string.h:221
std::__cxx11::basic_string<unsigned int, std::char_traits<unsigned int>, std::allocator<unsigned int> >::~basic_string basic_string.h:647
sf::String::~String String.hpp:45
main main.cpp:6
__libc_start_main 0x00007f2b288f1b97
_start 0x0000556bc8c90bea

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Failed to create input context for window
« Reply #7 on: June 08, 2020, 10:01:17 pm »
Ah, I forgot that you said you're using Conan :)

Given the stack trace, that would mean, that it isn't really crashing in regards to anything X11, but something in sf::String...

Can you try the following program:

#include <SFML/System.hpp>

int main()
{
    sf::String myString("Hello World");
}
 

If that still fails, then I question the Conan recipe or the binaries downloaded. A crash in std::basic_string is often an indication of a runtime version mismatch...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

nboisvert

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Failed to create input context for window
« Reply #8 on: June 08, 2020, 10:09:56 pm »
Still crashes but without the "Failed to create input context for window"

Code: [Select]
/home/nboisvert/CLionProjects/untitled/cmake-build-debug/bin/untitled
free(): invalid pointer

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

I guess you're right it might be something with sf::String... I don't know where to start to compare differences with the macOS. First thing is that the mac runs clang 11 and ubuntu g++ 7.5

nboisvert

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Failed to create input context for window
« Reply #9 on: June 08, 2020, 10:12:19 pm »
Got it! I did as suggested here https://github.com/bincrafters/community/issues/538#issuecomment-439412488

And I have the window opening.

Thank you for help and time helping me debbugging this, it's really appreciated!