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

Author Topic: Possible bug with loadFromFile  (Read 2480 times)

0 Members and 1 Guest are viewing this topic.

Qix

  • Full Member
  • ***
  • Posts: 139
  • I am Qix!
    • View Profile
    • Natoga Technologies
Possible bug with loadFromFile
« on: October 02, 2012, 05:15:46 am »
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
        EnableConsole();

// ...

// ...

        // Get command line
        int argc = 0;
        char** argv = CommandLineToArgvA(GetCommandLineA(), &argc);

        // If there were no images dropped...
        if(argc == 0)
        {
                // ...
                return 0;
        }

        sf::RenderWindow win; // Thought maybe it was because a window wasn't open (I read somewhere that
        win.create(sf::VideoMode(10, 10), "..."); // OpenGL may not init until a window is opened)

        // Init images
        deque<sf::Texture*> textures;
               
        // Load images
        for(int i = 0; i < argc; i++)
        {
                sf::Texture* img = new sf::Texture();
                if(!img->loadFromFile("test/test_1.png")) // RUNTIME ERROR
                {
                        // ...
                }
                textures.push_back(img);
        }
}
 

In the above code, upon the loadFromFile call (where it is marked), the program crashes and dumps running memory to the console.

Stack trace:
Code: [Select]
> msvcr110.dll!memcpy(unsigned char * dst=0x00676e70, unsigned char * src=0x00000000, unsigned long count=5044544) Line 367 Unknown
  msvcp110.dll!std::basic_streambuf<char,std::char_traits<char> >::sputn(const char * _Ptr=0x004d0ffb, __int64 _Count=6778480) Line 203 C++
  sfmlg.dll!std::operator<<<char,std::char_traits<char>,std::allocator<char> >(std::basic_ostream<char,std::char_traits<char> > & _Ostr={...}, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & _Str={...}) Line 521 C++
  sfmlg.dll!sf::priv::ImageLoader::loadImageFromFile(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & filename={...}, std::vector<unsigned char,std::allocator<unsigned char> > & pixels={...}, sf::Vector2<unsigned int> & size={...}) Line 126 C++
  sfmlg.dll!sf::Texture::loadFromFile(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & filename={...}, const sf::Rect<int> & area={...}) Line 160 C++
  ImageSequencer.exe!WinMain(HINSTANCE__ * hInstance=0x00150000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00542a83, int nShowCmd=1) Line 79 C++
  ImageSequencer.exe!__tmainCRTStartup() Line 528 C
  ImageSequencer.exe!WinMainCRTStartup() Line 377 C

In the file SFML\Graphics\ImageLoader.cpp,  line 126 says:

err() << "Failed to load image \"" << filename << "\". Reason : " << stbi_failure_reason() << std::endl;

At runtime, err() is showing that it has an address of 123 (which is not a valid pointer address at all, unless I'm missing something).
~ Qix
Creator of Rippl Studio
Code: [Select]
<danharibo> iostream: I don't do enough drugs to think that's a good idea.

Qix

  • Full Member
  • ***
  • Posts: 139
  • I am Qix!
    • View Profile
    • Natoga Technologies
Re: Possible bug with loadFromFile
« Reply #1 on: October 02, 2012, 05:21:33 am »
Actually, this might be a strings issue...

~ Qix
Creator of Rippl Studio
Code: [Select]
<danharibo> iostream: I don't do enough drugs to think that's a good idea.

Qix

  • Full Member
  • ***
  • Posts: 139
  • I am Qix!
    • View Profile
    • Natoga Technologies
Re: Possible bug with loadFromFile
« Reply #2 on: October 02, 2012, 05:35:49 am »
Derp, not a bug. Accidentally got debug/release builds and import libraries mixed up. Fixed.
~ Qix
Creator of Rippl Studio
Code: [Select]
<danharibo> iostream: I don't do enough drugs to think that's a good idea.

 

anything