From: Arnaud Giersch Date: Mon, 19 Jul 2021 08:42:38 +0000 (+0200) Subject: Fix crashes with recent versions of pybind11. X-Git-Tag: v3.29~203 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/58f311658032f3dfc9085db60f6b7957323ef7a4 Fix crashes with recent versions of pybind11. This is the first point from issue simgrid/simgrid#76. --- diff --git a/src/bindings/python/simgrid_python.cpp b/src/bindings/python/simgrid_python.cpp index eac19eb65a..78cb91cb98 100644 --- a/src/bindings/python/simgrid_python.cpp +++ b/src/bindings/python/simgrid_python.cpp @@ -13,10 +13,28 @@ #pragma GCC diagnostic ignored "-Wunused-value" #endif -#include +#ifndef NDEBUG +/* Many tests are failing after pybind11 commit ad6bf5cd39ca64b4a9bf846b84b11c4c8df1c8e1 "Adding PyGILState_Check() in + * object_api<>::operator(). (#2919)". + * See https://github.com/pybind/pybind11/commit/ad6bf5cd39ca64b4a9bf846b84b11c4c8df1c8e1 + * + * The failing tests are mostly those with boost/raw/sysv contexts. As a workaround, define NDEBUG before pybind11 + * includes. + */ +#define NDEBUG +#define NDEBUG_LOCALLY_DEFINED +#endif + #include // Must come before our own stuff + +#include #include +#ifdef NDEBUG_LOCALLY_DEFINED +#undef NDEBUG_LOCALLY_DEFINED +#undef NDEBUG +#endif + #if defined(__GNUG__) #pragma GCC diagnostic pop #endif