SFML-switch icon indicating copy to clipboard operation
SFML-switch copied to clipboard

Dynamic strings segmentation fault

Open RedTopper opened this issue 4 years ago • 1 comments

Subject of the issue

Dynamic strings rendered at different sizes crash SFML when running in Yuzu.

(Note: It's possible it also crashes a real switch, but I don't have one on hand to test with right now) (Note 2: It's also possible I don't know how C++ works)

Your environment

I'm using the latest release in this repository, and can successfully build using the provided Makefile in your example on MinGW (Msys2)

Steps to reproduce

Uncomment the line marked // <-- HERE to reproduce

extern int main()
{
    Result rc = romfsInit();

    sf::Font font;
    if (!font.loadFromFile("romfs:/sans.ttf"))
    {
        printf("Font not loaded\r\n");
        return EXIT_FAILURE;
    }

    sf::VideoMode mode = sf::VideoMode::getDesktopMode();
    sf::RenderWindow window(mode, "Hello World SFML Window");

    while (window.isOpen()) {
        sf::Event e;
        while (window.pollEvent(e)) {
            printf("Event: %u\n", e.type);
        }

        window.clear();
		
        std::string str("Hello");
        // str += ", world!"; // <-- HERE
        sf::Text message(str, font);
        message.setCharacterSize(60);
        window.draw(message);
        window.display();
    }

    return EXIT_SUCCESS;
}

Expected behavior

The top left should say Hello, world!

Actual behavior

image

RedTopper avatar Jul 13 '20 00:07 RedTopper

Also causes a crash dump on actual hardware.

RedTopper avatar Jul 13 '20 05:07 RedTopper