   [SDL & C++] Exception after main
  Hey.#include "SDL.h"int main(int argc, char* args[]){return 0;}That throws an exception after main. The exception comes from the (**onexitend)(); call in the code below (line is commented):static void __cdecl doexit (   int code,   int quick,   int retcaller   ){#ifdef _DEBUG   static int fExit = 0;#endif  /* _DEBUG */#ifdef CRTDLL   if (!retcaller && check_managed_app())   {  /*Only if the EXE is managed then we call CorExitProcess.Native cleanup is done in .cctor of the EXEIf the Exe is Native then native clean up should be donebefore calling (Cor)ExitProcess.  */  __crtCorExitProcess(code);   }#endif  /* CRTDLL */   _lockexit();   /* assure only 1 thread in exit path */   __TRY   if (_C_Exit_Done != TRUE) {  _C_Termination_Done = TRUE;  /* save callable exit flag (for use by terminators) */  _exitflag = (char) retcaller;  /* 0 = term, !0 = callable exit */  if (!quick) { /*  * do _onexit/atexit() terminators  * (if there are any)  *  * These terminators MUST be executed in reverse order (LIFO)!  *  * NOTE:  *  This code assumes that __onexitbegin points  *  to the first valid onexit() entry and that  *  __onexitend points past the last valid entry.  *  If __onexitbegin == __onexitend, the table  *  is empty and there are no routines to call.  */ _PVFV * onexitbegin = (_PVFV *)_decode_pointer(__onexitbegin); _PVFV * onexitend   = (_PVFV *)_decode_pointer(__onexitend); if (onexitbegin) {while ( --onexitend >= onexitbegin )/* * if current table entry is non-NULL, * call thru it. */if ( *onexitend != NULL )    (**onexitend)();  // EXCEPTION THROWN HERE }#ifndef CRTDLL /*  * do pre-terminators  */ _initterm(__xp_a, __xp_z);#endif  /* CRTDLL */  }#ifndef CRTDLL  /*   * do terminators   */  _initterm(__xt_a, __xt_z);#endif  /* CRTDLL */#ifdef _DEBUG  /* Dump all memory leaks */  if (!fExit && _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) & _CRTDBG_LEAK_CHECK_DF)  { fExit = 1;#ifndef CRTDLL __freeCrtMemory(); _CrtDumpMemoryLeaks();#endif  /* CRTDLL */  }#endif  /* _DEBUG */   }   /* return to OS or to caller */   __FINALLY  if (retcaller) _unlockexit(); /* unlock the exit code path */   __END_TRY_FINALLY   if (retcaller)  return;   _C_Exit_Done = TRUE;   _unlockexit(); /* unlock the exit code path */   __crtExitProcess(code);}Any ideas why this would be happening?Cheers.   
  Hey,  You need to  include a lot more information for me/anybody else to help.  Which compiler are you using?  How are your libraries/application compiled (which runtime?) What compiler defines are you defining?  Is this your code, or down in SDL?Most likely what is happening is you are trying to call a function pointer on a null or uninitialized pointer, which is jumping you out into to memory somewhere causing the exception.Cheers, Bob   ;  My guess is that if you include the sdl.h header, you need to go through the SDL_Init and SDL_Quit routines in your main().   ;  Oh, yes haha sorry. The project properties (command line options) are all in the first post in this thread.I debugged it, and the results of the debugging can be seen in the first post here.There a couple of threads because this issue has been spread out over time. :sMy code is literally the first sample I posted, so whatever you see there is what I am doing. I'm using Visual Studio with the default compiler (whatever that is :)).I tried initialising SDL and then calling SDL_Quit, but it still throws the same exception in the same place:#include "SDL.h"int main(int argc, char* args[]){    if(SDL_Init(SDL_INIT_EVERYTHING) == -1){return 1;}    SDL_Quit();return 0;}Cheers.   ;  Are you sure that the sdl.h that you're including is from the same version as the sdl.dll your app refers to?   ;Quote:Original post by KylotanAre you sure that the sdl.h that you're including is from the same version as the sdl.dll your app refers to?I wasn't sure, so I got the new version and set it up, did a full rebuild and it still does the same thing. I also got the newer versions of SDL_ttf, SDL_image and SDL_mixer just to be sure, but it still happens.Will the disassembly or memory window or registers window help? It's in the CodeGuru link I posted, but I can get the values of them again if you think it will help?Cheers.   ;Quote:Original post by MybowlcutQuote:Original post by KylotanAre you sure that the sdl.h that you're including is from the same version as the sdl.dll your app refers to?I wasn't sure, so I got the new version and set it up, did a full rebuild and it still does the same thing.You might want to check your pc for all instances of sdl.dll. A rebuild won't make any difference here if it's finding an old version of the dll in your Windows/System directory, for example. Something like Process Monitor can be used to track down exactly which dll is getting used. Admittedly this is clutching at straws somewhat.;  Wow that program is crazy... very cool. Unfortunately, I have no idea how to find where I am since it is storing events every millisecond+.Edit: I think I found it:Quote:8:59:17.9251531 PMsvchost.exe1980QueryOpenC:\Documents and Settings\Bill\My Documents\Visual Studio 2005\Projects\CHECKERS\Checkers_SDL\debug\SDL.dllSUCCESSCreationTime: 4/03/2009 2:54:57 PM, LastAccessTime: 11/03/2009 8:59:08 PM, LastWriteTime: 30/12/2007 11:07:40 PM, ChangeTime: 11/03/2009 1:34:04 PM, AllocationSize: 323,584, EndOfFile: 321,536, FileAttributes: A8:59:17.9257093 PMsvchost.exe1980CreateFileC:\Documents and Settings\Bill\My Documents\Visual Studio 2005\Projects\CHECKERS\Checkers_SDL\debug\SDL.dllSUCCESSDesired Access: Read EA, Read Attributes, Read Control, Disposition: Open, Options: , Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, Impersonating: NT AUTHORITY\SYSTEM, OpenResult: Opened8:59:17.9261925 PMsvchost.exe1980QueryFileInternalInformationFileC:\Documents and Settings\Bill\My Documents\Visual Studio 2005\Projects\CHECKERS\Checkers_SDL\debug\SDL.dllSUCCESSIndexNumber: 0x50000000132878:59:17.9266390 PMsvchost.exe1980CloseFileC:\Documents and Settings\Bill\My Documents\Visual Studio 2005\Projects\CHECKERS\Checkers_SDL\debug\SDL.dllSUCCESSBut they are the dlls I copied from the newly unzipped SDL. Is there an easier way to do this? I'm trying to use the filter but it just filters EVERYTHING. :s   ;  If you right click on an event for a given process (eg. yours), you can have it 'include' that process, which effectively excludes all others, making it easy to see what's what.It does look like it's using the right DLL in your case, though. Perhaps the SDL mailing list will be able to help you?   ;  Oh, ok. That's pretty nifty haha.Yeah, guess I'll try there.Cheers!   