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

Author Topic: Help on an Error after quitting  (Read 1737 times)

0 Members and 1 Guest are viewing this topic.

LedLoaf

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Email
Help on an Error after quitting
« on: November 19, 2020, 11:49:57 pm »
EDIT: So I decided to use the SFML DLLs instead of statically and I no longer get that error. Could anyone explain to me why that is and how I would correct it if I went back to static?

Hello,

After I close my application I get this error. I'm not sure how to track how I would fix this. I would appreciate some help. It bothers me that it appears every time I close the program, the program itself runs fine.


Unhandled exception at 0x00BFABC4 in DungeonGame.exe: 0xC0000005:
Access violation reading location 0x00000000.

(Brings me to GlContext.cpp)

void GlContext::acquireTransientContext()
{
    // Protect from concurrent access
    Lock lock(mutex);

    // If this is the first TransientContextLock on this thread
    // construct the state object
    if (!transientContext)
        transientContext = new TransientContext;

    // Increase the reference count
    transientContext->referenceCount++;  <----------( X ) 'error here'
}
 
« Last Edit: November 20, 2020, 12:12:11 am by LedLoaf »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Help on an Error after quitting
« Reply #1 on: November 20, 2020, 10:02:53 am »
You probably use some globally initialized SFML resource, which have an undefined destruction order, so the SFML global variables are destructed before your own SFML resource, causing a crash.

Don't use global or static variables, especially for SFML classes.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

LedLoaf

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Email
Re: Help on an Error after quitting
« Reply #2 on: November 20, 2020, 07:46:57 pm »
Appreciate it, that was the problem. I've had this problem a few times over the years and now that makes complete sense and I did suspect something like that but had no idea why.

Have a good one!