Changes between Version 59 and Version 60 of CompileApp


Ignore:
Timestamp:
Apr 18, 2013, 2:03:50 PM (11 years ago)
Author:
romw
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CompileApp

    v59 v60  
    5454==== Microsoft Specific Changes ====
    5555
    56 Dealing with the Invalid Parameter exception (0xc000000d):
    57 
    58 Starting with Visual Studio 2005, Microsoft re-vamped the whole C Runtime Library. Part of the re-vamp process was to do parameter checking on each function. Places that would normally return a NULL value now cause a structured exception to be thrown.
    59 
    60 The nature of this structured exception is different than most as they specifically coded it so that it will not engage the BOINC Runtime Debugger and it'll display a dialog box asking the user if they wish to debug the error. If the user cancels the error code 0xc000000d is returned without any more information.
    61 
    62 To get more information with this error you'll need to create a function like this:
    63 {{{
    64 #ifdef _WIN32
     56Recent versions of Visual Studio include changes to the C Runtime Library which throw up this error when an invalid parameter is passed to various functions:
     57
     58[[Image(runtimerror.png)]]
     59
     60To prevent this dialog from being displayed and presenting a bad user experience on the BOINC platform, please add this to your applications initialization:
     61{{{
     62#if defined(_MSC_VER) && (_MSC_VER >= 1400)
     63        _set_invalid_parameter_handler(AppInvalidParameterHandler);
     64#endif
     65}}}
     66
     67Where AppInvalidParameterHandler() is defined as:
     68{{{
     69#if defined(_MSC_VER) && (_MSC_VER >= 1400)
    6570void AppInvalidParameterHandler(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved ) {
    66         fprintf(
    67                 stderr,
    68                 "Invalid parameter detected in function %s. File: %s Line: %d\n",
    69                 function,
    70                 file,
    71                 line
    72         );
    73         fprintf(
    74                 stderr,
    75                 "Expression: %s\n",
    76                 expression
    77         );
    78         // Cause a Debug Breakpoint.
    7971        DebugBreak();
    8072}
    8173#endif
    8274}}}
    83 
    84 The following code block should be added after the call to boinc_diagnostics_init():
    85 {{{
    86 #ifdef _WIN32
    87         // Every once and awhile something looks at a std::vector or some other
    88         // CRT/STL construct that throws an exception when an invalid parameter
    89         // is detected.  In this case we should dump whatever information we
    90         // can and then bail.  When we bail we should dump as much data as
    91         // possible.
    92         _set_invalid_parameter_handler(AppInvalidParameterHandler);
    93 #endif
    94 }}}
    95 
    96 When this issues happens in the future it'll describe which CRT function call was passed an invalid parameter and it should dump out the callstack for all threads.
    97 
    98 The function blocks above overwrite the default behavior of the CRT when an invalid parameter is detected.
    99 
    10075
    10176