Author Archives: Ofek Shilon

C++ Const Constructability

[Inspired by CppQuiz #264] Take this code snippet: It fails to compile in gcc, with: error: ‘const struct C’ has no user-provided default constructor and the implicitly-defined constructor does not initialize ‘int C::i’ Clang and icc give similar error messages. … Continue reading

Posted in C++ | Leave a comment

Checking if your Graphics software runs on GPU

What are we asking exactly? This is actually not that easy to phrase. If you see anything on a screen, your software does make use of some graphics processing unit – but it is more likely you’re interested in particular … Continue reading

Posted in DirectX, Win32 | 1 Comment

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

CMake Rants

CMake is a highly popular ‘meta-build’ system: it is a custom declarative syntax that is used to generate build scripts for all major OSs and compilers (e.g., VS solutions and projects). Designing such a system is a formidable task, but … Continue reading

Posted in C++ | 19 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

On API-MS-WIN-XXXXX.DLL, and Other Dependency Walker Glitches

Dependency walker is the tool of choice for static dependency analysis of native binaries (it has some dynamic analysis too, but that niche at least has some alternative solutions). It is in a rather sorry state, however – development seems … Continue reading

Posted in Win32 | 22 Comments

Data Read Breakpoints – redux

The Problem ~5Y ago I blogged about data breakpoints. A hefty bit of the discussion was devoted to persistence of hardware breakpoints across a thread switch: all four implementations mentioned assume that HW breakpoints persist across thread boundaries, and some rough … Continue reading

Posted in Debugging, Visual Studio | 1 Comment