Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows: boost::python reinitializes itself with the wrong version #315

Open
xobs opened this issue Aug 15, 2019 · 1 comment
Open

windows: boost::python reinitializes itself with the wrong version #315

xobs opened this issue Aug 15, 2019 · 1 comment

Comments

@xobs
Copy link
Contributor

xobs commented Aug 15, 2019

I'm still trying to track this down, but I'll need to switch projects for a few weeks so I'd like to document this here.

When building nextpnr-ice40 on MSVC, it appears to include two different versions of Python. This is likely the reason why static builds crash whenever invoking a python script.

For example, if I build the Debug version of nextpnr-ice40, attach a debugger, and let it crash, we can see that it's crashing somewhere in libboost:

 	python37.dll!00007ffb938b2faf()	Unknown
>	boost_python37-vc142-mt-gd-x64-1_70.dll!boost::python::detail::init_module(PyModuleDef & moduledef, void(*)() init_function) Line 43	C++
 	nextpnr-ice40.exe!PyInit_nextpnrpy_ice40() Line 93	C++
 	python37_d.dll!_imp_create_builtin(_object * module, _object * spec) Line 1197	C
 	python37_d.dll!_PyMethodDef_RawFastCallDict(PyMethodDef * method, _object * self, _object * const * args, __int64 nargs, _object * kwargs) Line 497	C
 	python37_d.dll!_PyCFunction_FastCallDict(_object * func, _object * const * args, __int64 nargs, _object * kwargs) Line 582	C
 	python37_d.dll!PyCFunction_Call(_object * func, _object * args, _object * kwargs) Line 792	C
 	python37_d.dll!do_call_core(_object * func, _object * callargs, _object * kwdict) Line 4641	C
 	python37_d.dll!_PyEval_EvalFrameDefault(_frame * f, int throwflag) Line 3192	C
 	python37_d.dll!_PyEval_EvalCodeWithName(_object * _co, _object * globals, _object * locals, _object * const * args, __int64 argcount, _object * const * kwnames, _object * const * kwargs, __int64 kwcount, int kwstep, _object * const * defs, __int64 defcount, _object * kwdefs, _object * closure, _object * name, _object * qualname) Line 3930	C
 	python37_d.dll!_PyFunction_FastCallKeywords(_object * func, _object * const * stack, __int64 nargs, _object * kwnames) Line 440	C
 	python37_d.dll!call_function(_object * * * pp_stack, __int64 oparg, _object * kwnames) Line 4617	C
 	python37_d.dll!_PyEval_EvalFrameDefault(_frame * f, int throwflag) Line 3125	C
 	python37_d.dll!function_code_fastcall(PyCodeObject * co, _object * const * args, __int64 nargs, _object * globals) Line 283	C
 	python37_d.dll!_PyFunction_FastCallKeywords(_object * func, _object * const * stack, __int64 nargs, _object * kwnames) Line 408	C
 	python37_d.dll!call_function(_object * * * pp_stack, __int64 oparg, _object * kwnames) Line 4617	C
 	python37_d.dll!_PyEval_EvalFrameDefault(_frame * f, int throwflag) Line 3095	C
 	python37_d.dll!function_code_fastcall(PyCodeObject * co, _object * const * args, __int64 nargs, _object * globals) Line 283	C
 	python37_d.dll!_PyFunction_FastCallKeywords(_object * func, _object * const * stack, __int64 nargs, _object * kwnames) Line 408	C
 	python37_d.dll!call_function(_object * * * pp_stack, __int64 oparg, _object * kwnames) Line 4617	C
 	python37_d.dll!_PyEval_EvalFrameDefault(_frame * f, int throwflag) Line 3125	C
 	python37_d.dll!function_code_fastcall(PyCodeObject * co, _object * const * args, __int64 nargs, _object * globals) Line 283	C
 	python37_d.dll!_PyFunction_FastCallKeywords(_object * func, _object * const * stack, __int64 nargs, _object * kwnames) Line 408	C
 	python37_d.dll!call_function(_object * * * pp_stack, __int64 oparg, _object * kwnames) Line 4617	C
 	python37_d.dll!_PyEval_EvalFrameDefault(_frame * f, int throwflag) Line 3125	C
 	python37_d.dll!function_code_fastcall(PyCodeObject * co, _object * const * args, __int64 nargs, _object * globals) Line 283	C
 	python37_d.dll!_PyFunction_FastCallKeywords(_object * func, _object * const * stack, __int64 nargs, _object * kwnames) Line 408	C
 	python37_d.dll!call_function(_object * * * pp_stack, __int64 oparg, _object * kwnames) Line 4617	C
 	python37_d.dll!_PyEval_EvalFrameDefault(_frame * f, int throwflag) Line 3125	C
 	python37_d.dll!function_code_fastcall(PyCodeObject * co, _object * const * args, __int64 nargs, _object * globals) Line 283	C
 	python37_d.dll!_PyFunction_FastCallDict(_object * func, _object * const * args, __int64 nargs, _object * kwargs) Line 322	C
 	python37_d.dll!_PyObject_FastCallDict(_object * callable, _object * const * args, __int64 nargs, _object * kwargs) Line 98	C
 	python37_d.dll!object_vacall(_object * callable, char * vargs) Line 1198	C
 	python37_d.dll!_PyObject_CallMethodIdObjArgs(_object * obj, _Py_Identifier * name, ...) Line 1248	C
 	python37_d.dll!import_find_and_load(_object * abs_name) Line 1646	C
 	python37_d.dll!PyImport_ImportModuleLevelObject(_object * name, _object * globals, _object * locals, _object * fromlist, int level) Line 1754	C
 	python37_d.dll!builtin___import__(_object * self, _object * args, _object * kwds) Line 314	C
 	python37_d.dll!_PyMethodDef_RawFastCallDict(PyMethodDef * method, _object * self, _object * const * args, __int64 nargs, _object * kwargs) Line 515	C
 	python37_d.dll!_PyCFunction_FastCallDict(_object * func, _object * const * args, __int64 nargs, _object * kwargs) Line 582	C
 	python37_d.dll!_PyObject_FastCallDict(_object * callable, _object * const * args, __int64 nargs, _object * kwargs) Line 101	C
 	python37_d.dll!_PyObject_CallFunctionVa(_object * callable, const char * format, char * va, int is_size_t) Line 957	C
 	python37_d.dll!PyObject_CallFunction(_object * callable, const char * format, ...) Line 977	C
 	python37_d.dll!PyImport_Import(_object * module_name) Line 1936	C
 	python37_d.dll!PyImport_ImportModule(const char * name) Line 1390	C
 	nextpnr-ice40.exe!nextpnr_ice40::init_python(const char * executable, bool first) Line 252	C++
 	nextpnr-ice40.exe!nextpnr_ice40::CommandHandler::executeMain(std::unique_ptr<nextpnr_ice40::Context,std::default_delete<nextpnr_ice40::Context> > ctx) Line 292	C++
 	nextpnr-ice40.exe!nextpnr_ice40::CommandHandler::exec() Line 383	C++
 	nextpnr-ice40.exe!main(int argc, char * * argv) Line 233	C++
 	[External Code]	

Of note is that nextpnr-ice40.exe is calling into python37_d.dll (the debug version of the library), which then calls into nextpnr-ice40.exe, which then calls into boost, which finally calls into python37.dll (the non-debug version).

This may be related to microsoft/vcpkg#5097 which is an open issue, but as of right now it is not possible to build Python support into a static executable on Windows.

@mmicko
Copy link
Member

mmicko commented Aug 15, 2019

Yes, this is existing bug. Debug build with VS did not work previously as well due to this bug. But you should not have issues with Release builds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants