When doing a debug build of LLDB, python headers automatically force a link against python27_d.lib. Since obtaining a copy of python27_d.lib requires building python manually, we attempted to avoid requiring LLDB developers to build python themselves as a matter of convenience. This leads to undefined behavior.
To reproduce the failures, you can do the following:
- Build a debug build of LLDB on Windows with python enabled.
- Run LLDB
- Type "script" with no arguments.
When the python interpreter launches, you get a CRT error from the Visual Studio runtime. This is most likely due to the fact that in order to make this work, we #undef'ed _DEBUG, then included stdlib.h, then included python.h, then #define'd _DEBUG again. This leads to stdlib.h being included with a different defines in different translation units. For example, a TU which indirectly includes lldb-python.h will see a different pre-processed stdlib.h than a translation unit which does not include lldb-python.h