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

Author Topic: Debug assertion fail!  (Read 8945 times)

0 Members and 1 Guest are viewing this topic.

BlueMagic

  • Newbie
  • *
  • Posts: 49
    • View Profile
Debug assertion fail!
« on: September 13, 2011, 08:19:00 pm »
When exiting an application made with SFML 2.0 in VS 2010, I get this error

Quote
'UntitledSpirit.exe': Loaded 'B:\FacepalmAssociation\UntitledSpirit.exe', Symbols loaded.
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'B:\FacepalmAssociation\UntitledSpirit\Debug\sfml-system-d-2.dll', Symbols loaded.
'UntitledSpirit.exe': Loaded 'B:\FacepalmAssociation\UntitledSpirit\Debug\sfml-window-d-2.dll', Symbols loaded.
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\opengl32.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\glu32.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\ddraw.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\dciman32.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\setupapi.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\devobj.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\winmm.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'B:\FacepalmAssociation\UntitledSpirit\Debug\sfml-graphics-d-2.dll', Symbols loaded.
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Symbols loaded.
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\apphelp.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\AppPatch\AcLayers.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\shell32.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\shlwapi.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\userenv.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\profapi.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\winspool.drv', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\mpr.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\atiglpxx.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\atioglxx.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\version.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\atigktxx.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\aticfx32.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\atiadlxy.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\wtsapi32.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\psapi.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\wintrust.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\crypt32.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\msasn1.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\dinput.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\hid.dll', Cannot find or open the PDB file
'UntitledSpirit.exe': Loaded 'C:\Windows\SysWOW64\clbcatq.dll', Cannot find or open the PDB file
Windows has triggered a breakpoint in UntitledSpirit.exe.

This may be due to a corruption of the heap, which indicates a bug in UntitledSpirit.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while UntitledSpirit.exe has focus.

The output window may have more diagnostic information.
The program '[4372] UntitledSpirit.exe: Native' has exited with code 0 (0x0).


It happens only when I close the window created by SFML, and happens when doing 'return EXIT_SUCCESS' (Especifically when it is going through a destructor method of a class called TtfText I made. The method is empty and does not contain any instructions). I guess it's important to mention that this didn't happen with SFML 1.6. This is the header of the class, without the methods I implemented:

Code: [Select]

class TtfText :
public Entity
{
public:
static sf::Font* currentFont;  //By the way this is allocated with 'new' in TtfText.cpp

TtfText(void);
~TtfText(void);
TtfText(sf::String,int size,int,int);

private:
sf::Text text;
float duration;
float fade;
int startTime;
float fadeSpeed;
};


VS2010 takes me to dbgheap.c, line 2036, in CrtIsValidHeapPointer:
Code: [Select]
extern "C" _CRTIMP int __cdecl _CrtIsValidHeapPointer(
        const void * pUserData
        )
{
        if (!pUserData)
            return FALSE;

        if (!_CrtIsValidPointer(pHdr(pUserData), sizeof(_CrtMemBlockHeader), FALSE))
            return FALSE;

        return HeapValidate( _crtheap, 0, pHdr(pUserData) );
} //This is line 2036


If I don't create any objects of the class TtfText, the error doesn't happen. Does anyone have ANY idea why this could be happening?

Disch

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Debug assertion fail!
« Reply #1 on: September 13, 2011, 08:43:17 pm »
Smells like heap corruption.

You're likely stepping outside of array boundaries somewhere or writing to a bad pointer.

BlueMagic

  • Newbie
  • *
  • Posts: 49
    • View Profile
Debug assertion fail!
« Reply #2 on: September 13, 2011, 08:46:52 pm »
But that makes no sense. Why would it work on 1.6, and why does it happen when returning from main() in 'return EXIT_SUCCESS'? The destructors were  left default. Happens only when I create an object of the class TtfText.

Disch

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Debug assertion fail!
« Reply #3 on: September 13, 2011, 09:05:55 pm »
Quote
But that makes no sense.


Welcome to the wonderful world of heap corruption.  It might cause your program to crash.  It might cause it to do weird things.  Or it might work just fine with no hint of any problem.  What's more, which one it does might depend on the phase of the moon.

It's the worst/most difficult kind of bug to fix.  It's one of the reasons why people recommend you avoid using pointers directly.

Quote
Why would it work on 1.6


Because the heap would have been arranged differently and different (possibly less critical) things were being corrupted.

Quote
why does it happen when returning from main() in 'return EXIT_SUCCESS'?


Because the end of the program is when the heap's integrity is being examined and verified.

The actual problem is not happening when you exit main.  it's happening much earlier in the program.  It's only being discovered when main exits.

Quote
Happens only when I create an object of the class TtfText.


Then it's possible TtfText is what's corrupting the heap.

Or maybe not.  Like I said, heap corruption is weird and very hard to predict.  TtfText is definitely a good starting point, though.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Debug assertion fail!
« Reply #4 on: September 13, 2011, 09:45:44 pm »
You should launch the debugger, to see where it stops.

It's probably a known bug (the default font sometimes crashes when it's destroyed, at global exit).
Laurent Gomila - SFML developer

omeg

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
    • http://omeg.pl/
Debug assertion fail!
« Reply #5 on: September 13, 2011, 10:27:03 pm »
Try disabling "Visual Studio hosting process" somewhere in the project options. I had such problems with the .Net version and disabling .vshost solved it (not sure what was going on there).

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Debug assertion fail!
« Reply #6 on: September 13, 2011, 11:23:38 pm »
It looks very much like the default font bug - heap memory gets freed twice, resulting in a crash. This one needs sorting ASAP!
SFML 2.1

Disch

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Debug assertion fail!
« Reply #7 on: September 14, 2011, 01:01:03 am »
I guess I'm just too quick to blame heap corruption.  XD

Is this bug detailed somewhere?  It seems kind of strange that all you guys know about it but it hasn't been fixed yet.

EDIT:

I suppose I could try actually looking at the bugs page.  XD

https://github.com/SFML/SFML/issues/59


Don't mind me.

BlueMagic

  • Newbie
  • *
  • Posts: 49
    • View Profile
Debug assertion fail!
« Reply #8 on: September 14, 2011, 06:09:53 am »
Quote from: "Laurent"
You should launch the debugger, to see where it stops.

It's probably a known bug (the default font sometimes crashes when it's destroyed, at global exit).


Any temporary solution?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Debug assertion fail!
« Reply #9 on: September 14, 2011, 07:42:09 am »
Quote
Any temporary solution?

Static linking should solve it.
Laurent Gomila - SFML developer

BlueMagic

  • Newbie
  • *
  • Posts: 49
    • View Profile
Debug assertion fail!
« Reply #10 on: September 14, 2011, 08:55:28 pm »
Ok, so I linked statically (to do that I only defined SFML_STATIC, is that correct?).

It did not fix the problem, but it made it occur on the beginning on the program, when I create an object of TtfText (in the closing bracket '}'. VS takes me to an _ASSERTE instruction in dbheap.c) .

So naturally I try everything that comes to mind, including eliminating the passage of sf::String in the constructor. Now the problem occurs when I exit the program (VS also takes me to the same instruction, I think).

Next thing I try is eliminating sf::Text completely in TtfText. The problem is now completely gone. If I keep the passage of sf::String in the constructor of the TtfText, the problem still happens when I exit the program.

Any ideas? It seems to be a problem with either sf::String, or sf::Text, or both. I hope the information I brought is helpful.

EDIT: Release version works perfectly.
EDIT2: Release statically linked comes up with the same errors that Debug statically linked, wtf.

I still don't know if I'm correctly setting it up for static compiling. Apparently not, since I get messages that I need the Dlls when I run the .exe withough the dlls in the folder.

Richy19

  • Full Member
  • ***
  • Posts: 190
    • View Profile
Debug assertion fail!
« Reply #11 on: September 14, 2011, 09:49:37 pm »
You need to define SFML_STATIC and use the static libraries, sfml-xxxxx-s.lib

BlueMagic

  • Newbie
  • *
  • Posts: 49
    • View Profile
Debug assertion fail!
« Reply #12 on: September 14, 2011, 09:53:59 pm »
You sure? I thought that was for 1.6 only. 2.0 comes with Debug and Release configurations only, and they don't generate sfml-xxxx-s.lib files, I believe.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Debug assertion fail!
« Reply #13 on: September 14, 2011, 10:28:33 pm »
Quote
I thought that was for 1.6 only. 2.0 comes with Debug and Release configurations only, and they don't generate sfml-xxxx-s.lib files, I believe.

You should read the tutorial, not believe ;)
Laurent Gomila - SFML developer

BlueMagic

  • Newbie
  • *
  • Posts: 49
    • View Profile
Debug assertion fail!
« Reply #14 on: September 15, 2011, 12:36:11 am »
The other errors stilldont make ssne, if I eliminate the font it still happens,in any configuratuion.

 

anything