"Heap Corruption detected..."

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

Remember a few years ago when I sat with DJGPP and had a project with lots of .o-files and a makefile with bad depencies => changed c-files wouldn't always cause the right object files to be rebuilt = caused some really nasty bugs and sudden crashes! (Resorted to "make clean" and deleting all the .o files all the time...)

So yes, it's possible that you could have some depencies and some old compiled object code in there that the VC converter "lost in translation".

But, a clean build would be a clean build I think (even in VC-land), but still worth a try. I would probably rebuild the entire project, file by file..

Post

I'd try putting a breakpoint at line

Code: Select all

 _initterm( __xc_a, __xc_z );
of crtexe.c , (line 499 in vs2008, might be different in vs2010), and try to debug static/global variable initialization routines starting from there.


This is the code that does calls constructors for static/global variables, which is in crt0dat.c

Code: Select all

#ifdef CRTDLL
void __cdecl _initterm (
#else  /* CRTDLL */
static void __cdecl _initterm (
#endif  /* CRTDLL */
        _PVFV * pfbegin,
        _PVFV * pfend
        )
{
        /*
         * walk the table of function pointers from the bottom up, until
         * the end is encountered.  Do not skip the first entry.  The initial
         * value of pfbegin points to the first valid entry.  Do not try to
         * execute what pfend points to.  Only entries before pfend are valid.
         */
        while ( pfbegin < pfend )
        {
            /*
             * if current table entry is non-NULL, call thru it.
             */
            if ( *pfbegin != NULL )
                (**pfbegin)();
            ++pfbegin;
        }
}
Before main() is called, one of those variable initialization constructors might be corrupting the heap and this is how you can debug it.
~stratum~

Post

Thanks stratum, that's something I'll try to make sure everything's working the way it should.

Now, time for some UPDATE!

It took me 15 minutes to rebuild an old project (from when this thing worked in VC2010) and copy the new .cpp files and reorder things (with the occasional interruption from my daughter who wanted me to take a record of how many times she won a round of "Megaman 8-bit Deathmatch" - which of course happened only once :hihi: ) and guess what? The project now runs without any error :!: :!: :!: No heap corruption, no access violation, no nothing!!!! The exact same source code!!! I still have to run this under winDbg though.

EDIT: winDbg reported no errors.

Post Reply

Return to “DSP and Plugin Development”