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

Author Topic: sf::priv::MutexImpl::Lock() Access Violation  (Read 2267 times)

0 Members and 1 Guest are viewing this topic.

tokiwotomare

  • Newbie
  • *
  • Posts: 21
    • View Profile
sf::priv::MutexImpl::Lock() Access Violation
« on: April 09, 2011, 01:18:55 am »
I updated my files from SFML 1.6 to 2.0. The program worked okay before; after making some necessary modifications because of the new code, my first run crashes.

Call stack:
Code: [Select]
ntdll.dll!76eb69e0()
  [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
> Mindjob.exe!sf::priv::MutexImpl::Lock()  Line 52 + 0xc bytes C++
  Mindjob.exe!sf::Mutex::Lock()  Line 62 C++
  Mindjob.exe!sf::Lock::Lock(sf::Mutex & mutex)  Line 39 C++
  Mindjob.exe!sf::GlResource::GlResource()  Line 53 + 0xd bytes C++
  Mindjob.exe!sf::Image::Image()  Line 52 + 0x47 bytes C++
  Mindjob.exe!std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,sf::Image,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,sf::Image> > >::operator[](const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & _Keyval)  Line 215 + 0xb bytes C++
  Mindjob.exe!mj_file_cabinet::mj_file_cabinet()  Line 7 + 0x3e bytes C++
  Mindjob.exe!`dynamic initializer for 'cabinet''()  Line 20 + 0x28 bytes C++
  Mindjob.exe!_initterm(void (void)* * pfbegin, void (void)* * pfend)  Line 873 C
  Mindjob.exe!_cinit(int initFloatingPrecision)  Line 288 + 0xf bytes C
  Mindjob.exe!__tmainCRTStartup()  Line 262 + 0x7 bytes C
  Mindjob.exe!wmainCRTStartup()  Line 189 C
  kernel32.dll!75a91194()
  ntdll.dll!76ecb429()
  ntdll.dll!76ecb3fc()


The code in question (if I'm reading the call stack right):

Code: [Select]
mj_file_cabinet::mj_file_cabinet() {
// load our images
// TODO: error handling
image_map["megaman"].LoadFromFile("Sprite Sheets\\x_cut.jpg");
image_map["platform_1"].LoadFromFile("Sprite Sheets\\platform_1.png");
image_map["platform_2"].LoadFromFile("Sprite Sheets\\platform_2.png");

//load our sounds
//TODO: error handling here too
sound_map["ground_collide"].LoadFromFile("Sounds\\Land.wav");
}


"image_map" is declared in the header as std::map<std::string, sf::Image>.

Any ideas?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::priv::MutexImpl::Lock() Access Violation
« Reply #1 on: April 09, 2011, 09:36:08 am »
It seems like you're linking statically to SFML and using it at global startup (before main). You must avoid that, SFML has its own global variables and they might not be initialized yet when yours are executing their constructor.
Laurent Gomila - SFML developer

tokiwotomare

  • Newbie
  • *
  • Posts: 21
    • View Profile
sf::priv::MutexImpl::Lock() Access Violation
« Reply #2 on: April 09, 2011, 09:38:34 am »
Aha! Before I upgraded, I was linking the dynamic files.

I've moved everything into main and it's working. Thanks!

 

anything