Finally I've got the smallest possible program to file reproduce a nasty bug.
#include <stdio.h> #include <functional> void TestFunc1(const std::function<void()>& func) { printf("TestFunc1\n"); func(); } int main() { // set breakpoint to this line in Release mode TestFunc1([=] { }); return 0; }
Steps to reproduce:
- Compile in Release mode.
- Set breakpoint to line #11.
- Run the program using VS debugger.
- Wait for breakpoint.
- Optionally, create minidump at this point using Task Manager. DON'T use Visual Studio Debug\Save dump as... because it will remove breakpoints from memory.
- Continue execution of the program.
- An access violation will occur.
It's cool, because without this breakpoint everything works as expected. This problem exists even in Debug mode, but I can't make a small program to reproduce this bug.
There is a way to actually see this bug in disassembly of minidump:
Environment: Windows 10, Visual Studio 2017, x86, ICC 17.0.4.210 (I'm sure that at least 15.x and 16.x compilers are affected too on windows). I saw this bug in Visual Studio 2013, 2015 many years ago.