about _CRT_DEBUGGER_HOOK function.


  • My program crashed when it invoked one dll's function with debug mode.My code is below.

    DVDErrorThrower err;

    try {

     err = m_session->BeginDiscAccess(hModule, device, DAM_READ_ONLY, 0, 0);


    catch(dvd_eng_error e)


    return E_FAIL;


    The breakpoint is in _CRT_DEBUGGER_HOOK.


    #include <dbgint.h>

    #ifdef _DEBUG

    #include <internal.h>
    #include <limits.h>
    #include <mtdll.h>
    #include <malloc.h>
    #include <stdlib.h>

    _CRT_ALLOC_HOOK _pfnAllocHook = _CrtDefaultAllocHook;

    *int _CrtDefaultAllocHook() - allow allocation
    *       allow allocation
    *       all parameters ignored
    *       returns TRUE
    int __cdecl _CrtDefaultAllocHook(
            int nAllocType,
            void * pvData,
            size_t nSize,
            int nBlockUse,
            long lRequest,
            const unsigned char * szFileName,
            int nLine
            return 1; /* allow all allocs/reallocs/frees */

    #endif  /* _DEBUG */

    int _debugger_hook_dummy;

    #ifdef _M_IA64
    #define _CRT_DEBUGGER_HOOK __crt_debugger_hook
    #endif  /* _M_IA64 */

    void __cdecl _CRT_DEBUGGER_HOOK(int _Reserved)
        /* assign 0 to _debugger_hook_dummy so that the function is not folded in retail */
        _debugger_hook_dummy = 0;

    and the callstack is like below:

    > msvcr80.dll!_crt_debugger_hook(int _Reserved=)  Line 65 C
      msvcr80.dll!_invoke_watson(const wchar_t * pszExpression=0x00000000, const wchar_t * pszFunction=0x00000000, const wchar_t * pszFile=0x00000000, unsigned int nLine=0, unsigned int pReserved=0)  Line 181 + 0x7 bytes C++
      msvcr80.dll!_invalid_parameter_noinfo()  Line 99 + 0xc bytes C++
      [Frames below may be incorrect and/or missing, no symbols loaded for NeroAPIEngine.dll] 
      msvcr80.dll!malloc(unsigned int size=189077260)  Line 163 + 0x63 bytes C
      mfc80u.dll!operator new(unsigned int nSize=0)  Line 349 + 0x3 bytes C++

    And my Pc's environoment is :

    Vista ultimate.

    visual stdio 2005 sp1


    but if I ran my program step by step ,it would catch the exception the function threw. And also with release mode.the program worked well!

    I'm crazy.

    Can anybody help me?



    Monday, August 27, 2007 9:05 AM



    yeath,i have installed it.But it  crashes again.
    Tuesday, August 28, 2007 4:17 AM

All replies

  • Did you install the Vista update?
    Monday, August 27, 2007 6:17 PM

    yeath,i have installed it.But it  crashes again.
    Tuesday, August 28, 2007 4:17 AM
  • Same here, running XP. Never seen this one before... Happens with Release build and the stack shows functions being ran that were completely unrelated and should not have even been called... Any ideas?


    Wednesday, July 09, 2008 12:10 AM