Category Archives: VC++

On OMP_WAIT_POLICY

Some years ago I encountered a crash that I reduced down to the following toy code, composed of a dll: and a console app: As emphasized and commented, FreeLibrary causes a crash – typically (but not always) an access violation, … Continue reading

Posted in C++, VC++ | 2 Comments

Matlab’s mxArray Internals

Everything in Matlab is a Matrix. The scalar 4 is a 1×1 matrix with the single value 4. The string ‘asdf’ is a 4×1 (not a typo – it is in fact a column vector) matrix, with the 4 char … Continue reading

Posted in Debugging, Matlab, VC++ | 2 Comments

Tracking the Current Directory from the debugger: RtlpCurDirRef

Some rogue code was changing our current directory from under our feet, and we needed to catch it in action. I was looking for a memory location to set a data breakpoint on. (Note: for the remainder of this post … Continue reading

Posted in Debugging, VC++, Win32 | 1 Comment

Checking Memory Corruption from the debugger in 2016

It used to be something like But this trick requires quite a bit of adaptation to use on modern VS versions. First, the relevant module is now ucrtbased.dll – thanks to the universal CRT the expression is no longer version-dependent. … Continue reading

Posted in Debugging, VC++ | 2 Comments

On Matlab’s loadlibrary, proto file and pcwin64 thunk

Today we’ll try to shed some light on dark undocumented corners of Matlab’s external interfaces. Matlab provides several ways to call into external native code – if you have just the binaries for this code, the way is loadlibrary.  To … Continue reading

Posted in Matlab, VC++ | 15 Comments

An equivalent project (a project with the same global properties and tools version) is already present

Quick note: when you get this error while trying to add a VC project to your solution, good chance your project is missing a .filters file. Googling taught me only that the same error message had a different reason a … Continue reading

Posted in VC++, Visual Studio | Leave a comment

Tinkering with VS2015 (CTP 6)

Today I downloaded the latest VS bits and played around with the native debugger. It was a brief session and so would be the records of my impressions. J Universal CRT is here! And seems like a great idea. A … Continue reading

Posted in Debugging, VC++ | Leave a comment

Accelerating Debug Runs, Part 2: _ITERATOR_DEBUG_LEVEL

A previous post discussed the Windows Debug Heap – with the main motivation being how to avoid it, as it is just empty, expensive overhead, and it isn’t clear why it is on by default in the first place. Remarkably, … Continue reading

Posted in Debugging, VC++ | 1 Comment

Debugging Memory Corruption II

Some years ago I shared a trick that let’s you call _CrtCheckMemory from the debugger anywhere, without re-compilation.   The updated (as of VS2013) string to type at a watch window is: {,,msvcr120d.dll}_CrtCheckMemory() Let’s expand on that today, in two steps. … Continue reading

Posted in Debugging, VC++ | 4 Comments

UseDebugLibraries and Wrong Defaults for VC++ Project Properties

Many of the projects I’m working on seem to have wrong default properties in Debug configuration.  For example, ‘Runtime Library’ is explicitly set to /MDd but defaults to /MD. ‘Basic Runtime Checks’ is explicitly set to /RTC1 but defaults to  … Continue reading

Posted in MSBuild, VC++ | 5 Comments