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

Author Topic: SFML2: myMutex crash  (Read 2463 times)

0 Members and 1 Guest are viewing this topic.

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
SFML2: myMutex crash
« on: August 24, 2011, 11:01:38 pm »
Hi

I'm getting a 0xC0000005 crash when my sf::Font stuff is being destroyed at the end of the program.

In wglcontext.cpp, WglContext::CreateContext
Code: [Select]

      if (sharedContext)
        {
            // wglShareLists doesn't seem to be thread-safe
            static Mutex mutex;
            Lock lock(mutex); // CRASHES IN HERE

            if (!wglShareLists(sharedContext, myContext))
                Err() << "Failed to share the OpenGL context" << std::endl;
        }


myMutex contains:
-      myMutex   {DebugInfo=0xfeeefeee LockCount=-17891602 RecursionCount=-17891602 ...}   _RTL_CRITICAL_SECTION
+      DebugInfo   0xfeeefeee {Type=??? CreatorBackTraceIndex=??? CriticalSection=??? ...}   _RTL_CRITICAL_SECTION_DEBUG *
      LockCount   -17891602   long
      RecursionCount   -17891602   long
      OwningThread   0xfeeefeee   void *
      LockSemaphore   0xfeeefeee   void *
      SpinCount   4277075694   unsigned long

The 0xFEEEFEEE is, if I'm not mistaken, Microsoft's way of marking heap memory that has been deallocated.

Any ideas? I can easily replicate the problem but I can't easily remove portions to code to post here :(

Thanks
SFML 2.1

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
SFML2: myMutex crash
« Reply #1 on: August 24, 2011, 11:10:16 pm »
Stack trace:

    ntdll.dll!77b81c1d()    
    [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]   
    PR1030.exe!sf::priv::MutexImpl::Lock()  Line 52 + 0xc bytes   C++
    PR1030.exe!sf::Mutex::Lock()  Line 62   C++
    PR1030.exe!sf::Lock::Lock(sf::Mutex & mutex={...})  Line 39   C++
    PR1030.exe!sf::priv::WglContext::CreateContext(sf::priv::WglContext * shared=0x0263eba8, unsigned int bitsPerPixel=32, const sf::ContextSettings & settings={...})  Line 315 + 0x10 bytes   C++
    PR1030.exe!sf::priv::WglContext::WglContext(sf::priv::WglContext * shared=0x0263eba8)  Line 59   C++
    PR1030.exe!sf::priv::GlContext::New()  Line 145 + 0x28 bytes   C++
    PR1030.exe!`anonymous namespace'::GetInternalContext()  Line 90 + 0x5 bytes   C++
    PR1030.exe!sf::priv::GlContext::EnsureContext()  Line 138 + 0x7 bytes   C++
    PR1030.exe!sf::GlResource::EnsureGlContext()  Line 86   C++
    PR1030.exe!sf::Texture::~Texture()  Line 76   C++
>   PR1030.exe!sf::Font::Page::~Page()  + 0x4e bytes   C++
    PR1030.exe!std::pair<unsigned int const ,sf::Font::Page>::~pair<unsigned int const ,sf::Font::Page>()  + 0x19 bytes   C++
    PR1030.exe!std::_Tree_nod<std::_Tmap_traits<unsigned int,sf::Font::Page,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,sf::Font::Page> >,0> >::_Node::~_Node()  + 0x19 bytes   C++
    PR1030.exe!std::_Tree_nod<std::_Tmap_traits<unsigned int,sf::Font::Page,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,sf::Font::Page> >,0> >::_Node::`scalar deleting destructor'()  + 0x16 bytes   C++
    PR1030.exe!std::_Destroy<std::_Tree_nod<std::_Tmap_traits<unsigned int,sf::Font::Page,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,sf::Font::Page> >,0> >::_Node>(std::_Tree_nod<std::_Tmap_traits<unsigned int,sf::Font::Page,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,sf::Font::Page> >,0> >::_Node * _Ptr=0x0a5509f8)  Line 61   C++
    PR1030.exe!std::allocator<std::_Tree_nod<std::_Tmap_traits<unsigned int,sf::Font::Page,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,sf::Font::Page> >,0> >::_Node>::destroy(std::_Tree_nod<std::_Tmap_traits<unsigned int,sf::Font::Page,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,sf::Font::Page> >,0> >::_Node * _Ptr=0x0a5509f8)  Line 161 + 0x9 bytes   C++
    PR1030.exe!std::_Tree<std::_Tmap_traits<unsigned int,sf::Font::Page,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,sf::Font::Page> >,0> >::_Erase(std::_Tree_nod<std::_Tmap_traits<unsigned int,sf::Font::Page,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,sf::Font::Page> >,0> >::_Node * _Rootnode=0x0a5509f8)  Line 1078   C++
    PR1030.exe!std::_Tree<std::_Tmap_traits<unsigned int,sf::Font::Page,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,sf::Font::Page> >,0> >::clear()  Line 955   C++
    PR1030.exe!sf::Font::Cleanup()  Line 390   C++
    PR1030.exe!sf::Font::~Font()  Line 100   C++
    PR1030.exe!TextElement::~TextElement()  Line 46 + 0x45 bytes   C++
    PR1030.exe!std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,TextElement>::~pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,TextElement>()  + 0x58 bytes   C++
    PR1030.exe!std::_Tree_nod<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,TextElement,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 ,TextElement> >,0> >::_Node::~_Node()  + 0x5b bytes   C++
    PR1030.exe!std::_Tree_nod<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,TextElement,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 ,TextElement> >,0> >::_Node::`scalar deleting destructor'()  + 0x2b bytes   C++
    PR1030.exe!std::_Destroy<std::_Tree_nod<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,TextElement,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 ,TextElement> >,0> >::_Node>(std::_Tree_nod<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,TextElement,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 ,TextElement> >,0> >::_Node * _Ptr=0x04a824c0)  Line 61   C++
    PR1030.exe!std::allocator<std::_Tree_nod<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,TextElement,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 ,TextElement> >,0> >::_Node>::destroy(std::_Tree_nod<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,TextElement,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 ,TextElement> >,0> >::_Node * _Ptr=0x04a824c0)  Line 161 + 0x9 bytes   C++
    PR1030.exe!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,TextElement,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 ,TextElement> >,0> >::_Erase(std::_Tree_nod<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,TextElement,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 ,TextElement> >,0> >::_Node * _Rootnode=0x04a824c0)  Line 1078   C++
    PR1030.exe!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,TextElement,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 ,TextElement> >,0> >::_Erase(std::_Tree_nod<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,TextElement,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 ,TextElement> >,0> >::_Node * _Rootnode=0x090b1270)  Line 1076   C++
    PR1030.exe!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,TextElement,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 ,TextElement> >,0> >::clear()  Line 955   C++
    PR1030.exe!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,TextElement,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 ,TextElement> >,0> >::erase(std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,TextElement,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 ,TextElement> >,0> >::iterator _First=("B2_RANDOM",{textHandle="B2_RANDOM" fontFile={...} fontData={...} ...}), std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,TextElement,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 ,TextElement> >,0> >::iterator _Last=(<Bad Ptr>,{textHandle=<Bad Ptr> fontFile={...} fontData={...} ...}))  Line 921   C++
    PR1030.exe!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,TextElement,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 ,TextElement> >,0> >::_Tidy()  Line 1327 + 0x6d bytes   C++
    PR1030.exe!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,TextElement,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 ,TextElement> >,0> >::~_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,TextElement,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 ,TextElement> >,0> >()  Line 527   C++
    PR1030.exe!std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,TextElement,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 ,TextElement> > >::~map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,TextElement,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 ,TextElement> > >()  + 0x58 bytes   C++
    PR1030.exe!`dynamic atexit destructor for 'TextManager::textData''()  + 0x28 bytes   C++
    PR1030.exe!doexit(int code=0, int quick=0, int retcaller=0)  Line 553   C
    PR1030.exe!exit(int code=0)  Line 398 + 0xd bytes   C
    PR1030.exe!__tmainCRTStartup()  Line 333   C
    PR1030.exe!wWinMainCRTStartup()  Line 196   C
    kernel32.dll!758c3677()    
    ntdll.dll!77b59f02()    
    ntdll.dll!77b59ed5()    
    PR1030.exe!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,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 ,bool> >,0> >::iterator::operator++(int __formal=3670136)  Line 469 + 0xc bytes   C++
    PR1030.exe!std::_Tree<std::_Tmap_traits<int,sf::Texture const *,std::less<int>,std::allocator<std::pair<int const ,sf::Texture const *> >,0> >::erase(std::_Tree<std::_Tmap_traits<int,sf::Texture const *,std::less<int>,std::allocator<std::pair<int const ,sf::Texture const *> >,0> >::iterator _Where=(...,...)  Line 853 + 0x9 bytes   C++
    f8830142()
SFML 2.1

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
SFML2: myMutex crash
« Reply #2 on: August 24, 2011, 11:38:20 pm »
It might be related to this issue:
https://github.com/SFML/SFML/issues/59
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
SFML2: myMutex crash
« Reply #3 on: August 25, 2011, 10:30:22 am »
Hmm I don't think it is.

I don't have an ATI graphics card, and nor do I use the default SFML font.
This issue is really bugging me, and I need a fix before I can release my app.

Shall I submit a bug in Git for this?
SFML 2.1

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML2: myMutex crash
« Reply #4 on: August 25, 2011, 12:08:20 pm »
Do you have global SFML objects (variables that are destroyed at global exit)?

Quote
and nor do I use the default SFML font

Instanciating a sf::Text with its default constructor is enough to instanciate the default font.

Quote
Shall I submit a bug in Git for this?

We should discuss it first on the forum :)
Laurent Gomila - SFML developer

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
SFML2: myMutex crash
« Reply #5 on: August 27, 2011, 10:08:55 pm »
Yes I do, but in any case, why does this occur and what can be done about it?
SFML 2.1

gorgoroth666

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • RiseAgain
    • Email
Re: SFML2: myMutex crash
« Reply #6 on: July 19, 2012, 11:15:47 pm »
Sorry to dig this one year old topic but I also crashed at exit because of the defaultFont problem. I had to replace all my sf::Text by pointers. I'm pretty sure that's not the intended behaviour. Hope it will be fixed or annouced in the tutorials at least. I had it with both SFML 2 RC and a dev snapshot of SFML 2 RC. Anyway thank you for this API and keep up the good work Laurent.

tl;dr: this issue is still open ; use sf::Text * text  instead of sf::Text text 

 

anything