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

Author Topic: Closing window causes access violation  (Read 12261 times)

0 Members and 1 Guest are viewing this topic.

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Closing window causes access violation
« Reply #15 on: November 09, 2011, 04:43:37 pm »
Annoyingly, that didn't fix it.

This is my stack trace, if it's any help.

>   PR1037.exe!sf::priv::MutexImpl::Lock()  Line 52 + 0xc bytes   C++
    PR1037.exe!sf::Mutex::Lock()  Line 62   C++
    PR1037.exe!sf::Lock::Lock(sf::Mutex & mutex)  Line 39   C++
    PR1037.exe!sf::priv::WglContext::CreateContext(sf::priv::WglContext * shared, unsigned int bitsPerPixel, const sf::ContextSettings & settings)  Line 315 + 0x10 bytes   C++
    PR1037.exe!sf::priv::WglContext::WglContext(sf::priv::WglContext * shared)  Line 59   C++
    PR1037.exe!sf::priv::GlContext::New()  Line 145 + 0x28 bytes   C++
    PR1037.exe!`anonymous namespace'::GetInternalContext()  Line 90 + 0x5 bytes   C++
    PR1037.exe!sf::priv::GlContext::EnsureContext()  Line 138 + 0x7 bytes   C++
    PR1037.exe!sf::GlResource::EnsureGlContext()  Line 86   C++
    PR1037.exe!sf::Texture::~Texture()  Line 77   C++
    PR1037.exe!sf::Font::Page::~Page()  + 0x4e bytes   C++
SFML 2.1

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Closing window causes access violation
« Reply #16 on: November 09, 2011, 04:54:32 pm »
Can I see the full stack trace?
Laurent Gomila - SFML developer

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Closing window causes access violation
« Reply #17 on: November 09, 2011, 05:04:36 pm »
Sure!

    ntdll.dll!777518d7()    
    [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]   
    PR1037.exe!sf::priv::MutexImpl::Lock()  Line 52 + 0xc bytes   C++
    PR1037.exe!sf::Mutex::Lock()  Line 62   C++
    PR1037.exe!sf::Lock::Lock(sf::Mutex & mutex)  Line 39   C++
>   PR1037.exe!sf::priv::WglContext::CreateContext(sf::priv::WglContext * shared, unsigned int bitsPerPixel, const sf::ContextSettings & settings)  Line 315 + 0x10 bytes   C++
    PR1037.exe!sf::priv::WglContext::WglContext(sf::priv::WglContext * shared)  Line 59   C++
    PR1037.exe!sf::priv::GlContext::New()  Line 145 + 0x28 bytes   C++
    PR1037.exe!`anonymous namespace'::GetInternalContext()  Line 90 + 0x5 bytes   C++
    PR1037.exe!sf::priv::GlContext::EnsureContext()  Line 138 + 0x7 bytes   C++
    PR1037.exe!sf::GlResource::EnsureGlContext()  Line 86   C++
    PR1037.exe!sf::Texture::~Texture()  Line 77   C++
    PR1037.exe!sf::Font::Page::~Page()  + 0x4e bytes   C++
    PR1037.exe!std::_Pair_base<unsigned int const ,sf::Font::Page>::~_Pair_base<unsigned int const ,sf::Font::Page>()  + 0x19 bytes   C++
    PR1037.exe!std::pair<unsigned int const ,sf::Font::Page>::~pair<unsigned int const ,sf::Font::Page>()  + 0x16 bytes   C++
    PR1037.exe!std::pair<unsigned int const ,sf::Font::Page>::`scalar deleting destructor'()  + 0x16 bytes   C++
    PR1037.exe!std::_Destroy<std::pair<unsigned int const ,sf::Font::Page> >(std::pair<unsigned int const ,sf::Font::Page> * _Ptr)  Line 64   C++
    PR1037.exe!std::allocator<std::pair<unsigned int const ,sf::Font::Page> >::destroy(std::pair<unsigned int const ,sf::Font::Page> * _Ptr)  Line 213 + 0x9 bytes   C++
    PR1037.exe!std::_Dest_val<std::allocator<std::pair<unsigned int const ,sf::Font::Page> >,std::pair<unsigned int const ,sf::Font::Page> >(std::allocator<std::pair<unsigned int const ,sf::Font::Page> > & _Alval, std::pair<unsigned int const ,sf::Font::Page> * _Pdest)  Line 288   C++
    PR1037.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)  Line 1617 + 0x22 bytes   C++
    PR1037.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 1416   C++
    PR1037.exe!sf::Font::Cleanup()  Line 390   C++
    PR1037.exe!sf::Font::~Font()  Line 100   C++
    PR1037.exe!TextElement::~TextElement()  Line 60 + 0x66 bytes   C++
    PR1037.exe!std::_Pair_base<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,TextElement>::~_Pair_base<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,TextElement>()  + 0x54 bytes   C++
    PR1037.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>()  + 0x2b bytes   C++
    PR1037.exe!std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,TextElement>::`scalar deleting destructor'()  + 0x2b bytes   C++
    PR1037.exe!std::_Destroy<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,TextElement> >(std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,TextElement> * _Ptr)  Line 64   C++
    PR1037.exe!std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,TextElement> >::destroy(std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,TextElement> * _Ptr)  Line 213 + 0x9 bytes   C++
    PR1037.exe!std::_Dest_val<std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,TextElement> >,std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,TextElement> >(std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,TextElement> > & _Alval, std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,TextElement> * _Pdest)  Line 288   C++
    PR1037.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)  Line 1617 + 0x22 bytes   C++
    PR1037.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)  Line 1615   C++
    PR1037.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 1416   C++
    PR1037.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_const_iterator<std::_Tree_val<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> > > _First, std::_Tree_const_iterator<std::_Tree_val<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> > > _Last)  Line 1383   C++
    PR1037.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 1866 + 0xaa bytes   C++
    PR1037.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 792   C++
    PR1037.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> > >()  + 0x2b bytes   C++
    PR1037.exe!`dynamic atexit destructor for 'TextManager::textData''()  + 0x28 bytes   C++
    PR1037.exe!doexit(int code, int quick, int retcaller)  Line 567   C
    PR1037.exe!exit(int code)  Line 393 + 0xd bytes   C
    PR1037.exe!__tmainCRTStartup()  Line 284   C
    PR1037.exe!WinMainCRTStartup()  Line 189   C
    kernel32.dll!7635339a()    
    ntdll.dll!77729ed2()    
    ntdll.dll!77729ea5()
SFML 2.1

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Closing window causes access violation
« Reply #18 on: November 09, 2011, 05:10:10 pm »
This one is your fault: you have a global sf::Font instance. This messes up with SFML's globals, and produces the same bug as the default font.

Have you tried to link SFML statically?
Laurent Gomila - SFML developer

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Closing window causes access violation
« Reply #19 on: November 09, 2011, 05:10:25 pm »
mutex contains:

Code: [Select]


- mutex {myMutexImpl=0x0051b3d8 } sf::Mutex
sf::NonCopyable {...} sf::NonCopyable
- myMutexImpl 0x0051b3d8 {myMutex={...} } sf::priv::MutexImpl *
sf::NonCopyable {...} sf::NonCopyable
- myMutex {DebugInfo=0xfeeefeee LockCount=-17891602 RecursionCount=-17891602 ...} _RTL_CRITICAL_SECTION
- DebugInfo 0xfeeefeee {Type=??? CreatorBackTraceIndex=??? CriticalSection=??? ...} _RTL_CRITICAL_SECTION_DEBUG *
Type CXX0030: Error: expression cannot be evaluated
CreatorBackTraceIndex CXX0030: Error: expression cannot be evaluated
CriticalSection CXX0030: Error: expression cannot be evaluated
+ ProcessLocksList {Flink=??? Blink=??? } _LIST_ENTRY
EntryCount CXX0030: Error: expression cannot be evaluated
ContentionCount CXX0030: Error: expression cannot be evaluated
Flags CXX0030: Error: expression cannot be evaluated
CreatorBackTraceIndexHigh CXX0030: Error: expression cannot be evaluated
SpareWORD CXX0030: Error: expression cannot be evaluated
LockCount -17891602 long
RecursionCount -17891602 long
OwningThread 0xfeeefeee void *
LockSemaphore 0xfeeefeee void *
SpinCount 4277075694 unsigned long




Maybe this isn't the same bug........?
SFML 2.1

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Closing window causes access violation
« Reply #20 on: November 09, 2011, 05:16:07 pm »
Quote from: "Laurent"
This one is your fault: you have a global sf::Font instance. This messes up with SFML's globals, and produces the same bug as the default font.

Have you tried to link SFML statically?


There is only one sf::Font, in a class called TextElement, which I create multiple instances of.

Yes SFML is static linked, as this is the only way we can use it without a nightmare of WinSxS issues.
SFML 2.1

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Closing window causes access violation
« Reply #21 on: November 09, 2011, 08:16:11 pm »
Quote
There is only one sf::Font, in a class called TextElement, which I create multiple instances of.

...and one of them is destroyed at global exit. Avoiding globals is the best way to avoid problems ;)
Laurent Gomila - SFML developer

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Closing window causes access violation
« Reply #22 on: November 09, 2011, 10:23:40 pm »
Hmm.

I might create maybe 8 or 9 of these, and all of them are destroyed at global exit correctly, but the final one causes the crash.

I have modified my SFML library to remove the default font in the constructors, which didn't fix it.

Any other ideas? We might just have to stop using sf::Font altogether if it's causing that much of a problem.
SFML 2.1

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Closing window causes access violation
« Reply #23 on: November 09, 2011, 10:46:42 pm »
Any OpenGL resource that you destroy at global exit will cause problems. Don't do this, really. You should be able to release all your SFML resources before the end of main(), don't you?
Laurent Gomila - SFML developer

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Closing window causes access violation
« Reply #24 on: November 10, 2011, 12:02:18 pm »
OK, I am manually destroying these before the program exits, and it has fixed this problem.

Thanks Laurent, I really appreciate your help :)
SFML 2.1

 

anything