Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix crashes with recent versions of pybind11.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 19 Jul 2021 08:42:38 +0000 (10:42 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 19 Jul 2021 08:42:38 +0000 (10:42 +0200)
This is the first point from issue simgrid/simgrid#76.

src/bindings/python/simgrid_python.cpp

index eac19eb..78cb91c 100644 (file)
 #pragma GCC diagnostic ignored "-Wunused-value"
 #endif
 
-#include <pybind11/functional.h>
+#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 <pybind11/pybind11.h> // Must come before our own stuff
+
+#include <pybind11/functional.h>
 #include <pybind11/stl.h>
 
+#ifdef NDEBUG_LOCALLY_DEFINED
+#undef NDEBUG_LOCALLY_DEFINED
+#undef NDEBUG
+#endif
+
 #if defined(__GNUG__)
 #pragma GCC diagnostic pop
 #endif