| 53 | |
| 54 | ==== Microsoft Specific Changes ==== |
| 55 | |
| 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 |
| 65 | void 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. |
| 79 | DebugBreak(); |
| 80 | } |
| 81 | #endif |
| 82 | }}} |
| 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 | |
| 100 | |