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

Author Topic: Run-Time Check Failure #2 - Stack around the variable 'font' was corrupted.  (Read 5806 times)

0 Members and 1 Guest are viewing this topic.

CreaM

  • Newbie
  • *
  • Posts: 36
    • View Profile
Hi, Iv got this source code and when i close my window the program breaks and writes this error. There is so many people with this problem on net, but im bigginer and i realy dont know whats wrong. :o
thx.

#include <SFML/Graphics.hpp>
#include <windows.h>
#include <iostream>

int main()
{
        sf::RenderWindow window(sf::VideoMode(800, 650), "My window");
        //----------------
        sf::Font font;
        if (!font.loadFromFile("arial.ttf"))
                return 1;

        sf::Text text;
        text.setFont(font); // font is a sf::Font
        text.setString("Hello world");// set the string to display
        text.setCharacterSize(24); // in pixels, not points!
        text.setColor(sf::Color::Red);
        text.setStyle(sf::Text::Bold | sf::Text::Underlined);
        text.setPosition(sf::Vector2f(500, 430));

        //----------------
    while (window.isOpen())
{
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }
                window.clear(sf::Color::Black);
                //------------------
                window.draw(text);
                //------------------
        window.display();
    }

    return 0;
}

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Make sure you use the right library version for your compiler and that the debug/release modes match.

Then provide us the stack trace and full build command.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

CreaM

  • Newbie
  • *
  • Posts: 36
    • View Profile
in full build command was written dozen times that Cannot find or open the PDB file,than
The thread 'Win32 Thread' (0x1120) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1780) has exited with code 0 (0x0).and
Run-Time Check Failure #2 - Stack around the variable 'text' was corrupted.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
I don't care for these warnings I care for the command itself.

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

CreaM

  • Newbie
  • *
  • Posts: 36
    • View Profile
1>------ Rebuild All started: Project: hope, Configuration: Debug Win32 ------
1>  Microsoft (R) C/C++ Optimizing Compiler Version 17.00.50727.1 for x86
1>  Copyright (C) Microsoft Corporation.  All rights reserved.
1>  
1>  cl /c /I"C:\Program Files\SFML-2.1\include" /ZI /nologo- /W3 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Yc"stdafx.h" /Fp"Debug\hope.pch" /Fo"Debug\\" /Fd"Debug\vc110.pdb" /Gd /TP /analyze- /errorReport:prompt stdafx.cpp
1>cl : Command line warning D9035: option 'nologo-' has been deprecated and will be removed in a future release
1>  
1>  stdafx.cpp
1>  Microsoft (R) C/C++ Optimizing Compiler Version 17.00.50727.1 for x86
1>  Copyright (C) Microsoft Corporation.  All rights reserved.
1>  
1>  cl /c /I"C:\Program Files\SFML-2.1\include" /ZI /nologo- /W3 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc110.pdb" /Gd /TP /analyze- /errorReport:prompt hope.cpp
1>cl : Command line warning D9035: option 'nologo-' has been deprecated and will be removed in a future release
1>  
1>  hope.cpp
1>  Microsoft (R) Incremental Linker Version 11.00.50727.1
1>  Copyright (C) Microsoft Corporation.  All rights reserved.
1>  
1>  "/OUT:C:\Users\.\documents\visual studio 2010\Projects\hope\Debug\hope.exe" /INCREMENTAL "/LIBPATH:C:\Program Files\SFML-2.1\lib" "sfml-system-d.lib" "sfml-window-d.lib" "sfml-graphics-d.lib" "sfml-network-d.lib" "sfml-audio-d.lib" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST "/ManifestFile:Debug\hope.exe.intermediate.manifest" "/MANIFESTUAC:level='asInvoker' uiAccess='false'" /DEBUG "/PDB:C:\Users\.\documents\visual studio 2010\Projects\hope\Debug\hope.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT "/IMPLIB:C:\Users\.\documents\visual studio 2010\Projects\hope\Debug\hope.lib" /MACHINE:X86 Debug\hope.exe.embed.manifest.res
1>  Debug\hope.obj
1>  Debug\stdafx.obj
1>  Microsoft (R) Incremental Linker Version 11.00.50727.1
1>  Copyright (C) Microsoft Corporation.  All rights reserved.
1>  
1>  "/OUT:C:\Users\.\documents\visual studio 2010\Projects\hope\Debug\hope.exe" /INCREMENTAL "/LIBPATH:C:\Program Files\SFML-2.1\lib" "sfml-system-d.lib" "sfml-window-d.lib" "sfml-graphics-d.lib" "sfml-network-d.lib" "sfml-audio-d.lib" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST "/ManifestFile:Debug\hope.exe.intermediate.manifest" "/MANIFESTUAC:level='asInvoker' uiAccess='false'" /DEBUG "/PDB:C:\Users\.\documents\visual studio 2010\Projects\hope\Debug\hope.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT "/IMPLIB:C:\Users\.\documents\visual studio 2010\Projects\hope\Debug\hope.lib" /MACHINE:X86 Debug\hope.exe.embed.manifest.res
1>  Debug\hope.obj
1>  Debug\stdafx.obj
1>  hope.vcxproj -> C:\Users\.\documents\visual studio 2010\Projects\hope\Debug\hope.exe
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
And you got SFML from where?


And the call stack when it crashes is still missing.

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

CreaM

  • Newbie
  • *
  • Posts: 36
    • View Profile
ok, its not by a source code. - nomather the code, the Run-Time Check Failure #2 appears...dont you know where could be problem?
« Last Edit: April 04, 2014, 04:15:09 pm by . »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
What exact package did you download?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

CreaM

  • Newbie
  • *
  • Posts: 36
    • View Profile
Oh, i just created a new project and all is working now, probably i just messed up smth in prophetis...
im sorry, im noob, thanks for patience