SFML community forums

Help => General => Topic started by: Soul on May 13, 2014, 12:27:54 pm

Title: strange problem
Post by: Soul on May 13, 2014, 12:27:54 pm
Hey, i have problem with my map editor, i don't know why, but when i add one more object from tgui, sfml and type higher than char my app crash, only in menu class, why?, when i debug everything work fine, but when i want run exe it crash...

that print console
Quote
Process returned -1073741676 (0xC0000094)   execution time : 2.281 s
Press any key to continue.
Title: Re: strange problem
Post by: eXpl0it3r on May 13, 2014, 12:29:11 pm
Please read and apply this (http://en.sfml-dev.org/forums/index.php?topic=5559.0).
Title: Re: strange problem
Post by: Soul on May 13, 2014, 12:54:38 pm
well, my english isn't pretty good, sorry, anyway my problem is with this class, at the moment everything work fine, but when i declare one more type upper than char (for eg. int or float) app will it crash, in debuger everything work fine too, i was tryed use pointers, but it don't work too :PP, problem can be with memory?
#ifndef MENU_H
#define MENU_H
#include <TGUI/TGUI.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
#include "../include/Map.h"
#define THEME_CONFIG_FILE "gui/BabyBlue.conf"

class Menu
{
    public:
        void LoadMenu(sf::RenderWindow &wnd);
        bool Callback(Map &m);
        void Event(sf::Event &event);
        void Draw();
        void hide();
        void getTile();
    protected:
    tgui::Gui gui;
    tgui::Gui tilegui;
    tgui::MenuBar::Ptr menu;
    tgui::Callback callback;
    tgui::ChildWindow::Ptr window;
    tgui::Button::Ptr Create;
    tgui::Button::Ptr Load;
    tgui::EditBox::Ptr name;
    tgui::EditBox::Ptr tilepath;
    tgui::EditBox::Ptr objectpath;
    tgui::EditBox::Ptr tilesize;
    tgui::EditBox::Ptr x;
    tgui::EditBox::Ptr y;
    sf::RenderWindow *W;
    sf::RenderWindow T;
    sf::Sprite tilespr;
    sf::Texture *tex;
    sf::Vector2i pos;
    sf::Mouse mouse;
    sf::Vector2i WinPos;
    bool showT;
    bool showM;
    Map *mapa;
};
Title: Re: strange problem
Post by: Laurent on May 13, 2014, 01:18:50 pm
Can you show the code surrounding the location where it crashes?
Title: Re: strange problem
Post by: Soul on May 13, 2014, 01:30:22 pm
it crash in debug mode only lol, it crash when i declare one typ
in this code everything is ok, to crash i must declare one variable... i'll try later rebuild my debug mode libs, maybe it help...
app crash at startup, it's strange, anyway i can upload my project and you can compile it and check, maybe it crashesh only on my i5 hmmm
Title: Re: strange problem
Post by: eXpl0it3r on May 13, 2014, 01:41:41 pm
If it randomly crashes when changing unrelated code, then you most likely have a heap/stack corruption.
What you can do, is start your debugger and check the variables for stack overflows and out of bound memory access. Minimize your code, so the issues become obvious or it's so small that you can post it here as minimal and complete code.
Title: Re: strange problem
Post by: Jesper Juhl on May 13, 2014, 06:03:38 pm
Some tools that I find often help tracking down issues like that:

Valgrind: http://valgrind.org/
Address sanitizer: http://clang.llvm.org/docs/AddressSanitizer.html
Clang Analyzer: http://clang-analyzer.llvm.org/
Title: Re: strange problem
Post by: eXpl0it3r on May 13, 2014, 06:18:16 pm
First he should learn good C++ practices so that such errors nearly never happen and at the same time learn how to use a debugger. This is far more important than other tools.
Title: Re: strange problem
Post by: Jesper Juhl on May 13, 2014, 06:34:27 pm
I'm not disagreeing with that. But the tools are still good to know about and other people may also read the thread and find the links useful.  :)
Title: Re: strange problem
Post by: Soul on May 14, 2014, 12:04:05 pm
http://www44.zippyshare.com/v/1075079/file.html

here is complete my mapeditor source code, the problem is in menu.h, if you can compile it in debug mode (not debuger...)
then use  one of variables in comments and check what's wrong, my debuger can't nothing find because everything work fine
Title: Re: strange problem
Post by: Doodlemeat on May 16, 2014, 01:26:07 am
    ///sf::RectangleShape dsadas;       this declaration will crash app
    ///int dasdas;                          or this

I can't see any include of the SFML graphics namespace.
Try to write #include <SFML/Graphics/RectangleShape.hpp>