user1646993
user1646993

Reputation:

Onexit.c error in visual studio?

When i try and run my program in release mode it goes straigth to

Unhandled exception at 0x6f2426ef (msvcr100.dll) in FPS Game.exe: 0xC0000005: Access violation writing location 0x12817c19.

this is in the static _onexit_t __cdecl _dllonexit_nolock function in onxit.c on line 325 : *((*pend)++) = (_PVFV)func;

and i dont know why i have tried many things i cant get it too work i have sdl linked to my application if thats the reason but i really need help with this.

This is the code which is going wrong its microsofts :

static _onexit_t __cdecl _dllonexit_nolock (
        _onexit_t func,
        _PVFV ** pbegin,
        _PVFV ** pend
        )
{
        _PVFV   *p=NULL;
        size_t oldsize;

        /*
         * First, make sure the table has room for a new entry
         */
        if ( (oldsize = _msize_crt(*pbegin)) <= (size_t)((char *)(*pend) -
            (char *)(*pbegin)) )
        {
            /*
             * not enough room, try to grow the table
             */
            size_t grow=__min(oldsize, MAXINCR * sizeof(_PVFV));
            if((_HEAP_MAXREQ-grow<oldsize) ||
                ((p = (_PVFV *)_realloc_crt((*pbegin), oldsize + grow)) == NULL))
            {
                /*
                 * failed, try to grow by ONEXITTBLINCR
                 */
                grow=MININCR * sizeof(_PVFV);
                if ( (_HEAP_MAXREQ-grow<oldsize) ||
                    ((p = (_PVFV *)_realloc_crt((*pbegin), oldsize + grow)) == NULL ))
                {
                    /*
                     * failed again. don't do anything rash, just fail
                     */
                    return NULL;
                }
            }

            /*
             * update (*pend) and (*pbegin)
             */
            (*pend) = p + ((*pend) - (*pbegin));
            (*pbegin) = p;
        }

        /*
         * Put the new entry into the table and update the end-of-table
         * pointer.
         */
         *((*pend)++) = (_PVFV)func;

        return func;

}

Upvotes: 2

Views: 794

Answers (1)

Richard Harrison
Richard Harrison

Reputation: 19403

Based on many years of experience and many similar experiences one of my rules of thumb is "No you haven't just found a bug in the compiler".

Firstly build the release with debug info - this should at least let you see the stack and maybe give you a clue what's going wrong.

Often this sort of problem is caused by

  • using the wrong linker settings, or libraries (this is unique to MSVC / windows)
  • linking against a release library that isn't built with the same code generation options;
  • not initializing variables correctly (which often doesn't show up in debug mode)
  • Not having consistent compilation options across all of the projects

Upvotes: 1

Related Questions